HashSet and LinkedHashSet

HashSet (Since Java 1.2):  HashSet is achild interface of Set.  Underlying data structure is HashTable.(Internally it’s a HashMap. See HashTable code)  Insertion order is not preserved.  Duplicates are not allowed.  Allows null element ( only one 🙂 since set will not allow duplicates).  Default initial capacity is 16.  Default load factor is 0.75f.  Threshold = […]

ArrayList,LinkedList,Vector and Stack

ArrayList (Since Java 1.2): Grow able Array implementation of List interface. Insertion order is preserved. Duplicate elements are allowed. Multiple null elements of insertion are allowed. Default initial capacity of an ArrayList is 10. The capacity grows with the below formula, once ArrayList reaches its max capacity. newSize/newCapacity= (oldCapacity * 3)/2 + 1

Output: […]

How To Sort Hashmap By Value in Java

In real-time, you may be getting hashmap result from the server and you want to display the hashmap values in sorted order Or you may need to display the values in a drop down but in a sorted order. For example, from server we are getting different types of pizza’s with the item as key […]