How to get maximum value from the Collection (for example ArrayList)?

You can use the Collections API to achieve what you want easily – read efficiently – enough
Javadoc for Collections.max

Collections.max(arrayList);

Returns the maximum element of the given collection, according to the natural ordering of its elements. All elements in the collection must implement the Comparable interface.

Leave a Comment