Java examples for Collection Framework:HashSet
Find Minimum element of HashSet
import java.util.HashSet; import java.util.Collections; public class Main { public static void main(String[] args) { // w w w.j a v a 2 s . com //create a HashSet object HashSet hashSet = new HashSet(); //Add elements to HashSet hashSet.add(new Long("91111111111111111111")); hashSet.add(new Long("4")); hashSet.add(new Long("2")); hashSet.add(new Long("2")); hashSet.add(new Long("3")); Object obj = Collections.min(hashSet); System.out.println("Minimum Element of Java HashSet is : " + obj); } }