I have an Enum with int values:
public enum Enum{
ONE(1) ,
TWO(2) ,
THREE(3),
FOUR(4) ;
private final long id;
Enum(final long id) {
this.id = id;
}
@Override
public long getId() {
return this.id;
}
}
I am trying to print the ids of all enum in a string using java stream. Something like this:
String ids = Stream.of(Enum.values())
.map(value -> value.getId())
.collect(Collectors.joining(",");
I tried mapToObj and boxed but my IDE doesn't recognize it. Please help