The java.util Collections min is a part of the Java Collections Framework that returns the minimum element of the given collection, based on the natural ordering of its elements.
Example 1:
List list = Arrays.asList(5, 3, 7, 1, 4); System.out.println(Collections.min(list));
This code returns 1, as it is the minimum element of the list.
Example 2:
Set set = new HashSet<>(); set.add("apple"); set.add("orange"); set.add("banana"); System.out.println(Collections.min(set));
This code returns "apple", as it is the minimum element of the set in terms of lexicographic order.
The package library for java.util Collections min is java.util.
Java Collections.min - 30 examples found. These are the top rated real world Java examples of java.util.Collections.min extracted from open source projects. You can rate examples to help us improve the quality of examples.