I have the following pojo:
class MyPojo {
String name;
int priority;
}
I have a List<MyPojo>
. Now, I want to retrieve all elements which have the highest priority. The order of those elements does not matter.
Is this possible with Java streams? I think I should first group by priority and then get all elements belonging to the highest priority, but I am not sure how to do this in an efficient manner.