Is there an easy way to get the max value from one field of an object in an arraylist of objects?
For example, out of the following object, I was hoping to get the h
With Java 8 you can use stream() together with it's predefined max() function and Comparator.comparing() functionality with lambda expression:
stream()
max()
Comparator.comparing()
ValuePairs maxValue = values.stream().max(Comparator.comparing(v -> v.getMValue())).get();