Comparator in Java

Comparator Interface is a very useful interface which is used to sort the objects on some predefined conditions. Usually when we want to sort Integer type ArrayList then we use Collections.sort(arrayListName). This will sort the list of integers in ascending order. But what if we want to sort Student objects based on the marks students … Read more

HashMap in Java

HashMap is one of the most used collections in Java. It is used to store key value pair. The size of HashMap increases as more key value pairs are added. Let us look at sample declaration of HashMap: HashMap<Integer,String> dummy = new HashMap<Integer,String>(); In above sample the key stored will be of type Integer and … Read more