How to get the elements which specified field value value is max from object list?
public class MyObj {
private String name;
private int value;
// getter & setter
}
List<MyObj> list = Arrays.asList(
new MyObj("a", 1),
new MyObj("b", 1),
new MyObj("c", 2),
new MyObj("d", 2),
new MyObj("e", 3),
new MyObj("f", 3)
);
// how to get the objs which value is max, here is MyObj("e", 3) and MyObj("f", 3)
List<MyObj> maxList = //todo ;
Note: not to get the max value