Have a Question?

If you have any question you can ask below or enter what you are looking for!

Category: Collection Framework

Difference between HashMap and LinkedHashMap?

Difference between HashMap and LinkedHashMap?

Difference between HashMap and LinkedHashMap? It is the child class of HashMap. The LinkedHashMap class is very similar to HashMap in most aspects. However, the linked hash map is based on both hash table and the linked list to enhance the functionality of hash map. It maintains a doubly-linked list running through all its . . . Read more

Difference between HashMap & Hashtable in Java?

Difference between HashMap & Hashtable in Java?

Difference between HashMap & Hashtable in Java? The underlying data-structure is HashTable. Insertion order is not preserved and it is based on HashCode is keys. Duplicate keys are not allowed but values can be duplicated. Heterogeneous objects are allowed for both Key and value. Null is allowed for Key(only once). . . . Read more

Comparison table of SET Implemented classes?

Comparison table of SET Implemented classes?

Java Set is a collection of elements (Or objects) that contains no duplicate elements. Java Set is an interface that extends Collection interface. Unlike List, Java Set is NOT an ordered collection, it’s elements does NOT have a particular order. Java Set does NOT provide a control over the position where you . . . Read more

Difference between Comparator and Comparable in Java?

Difference between Comparator and Comparable in Java?

Difference between Comparator and Comparable in Java? Comparator[I] It is present in java.lang package and it contains only one method. [highlight]compareTo()[/highlight];   If we are depending on default natural sorting order then while adding the object into the TreeSet JVM will call compareTo() method.  If default natural sorting order not available or . . . Read more

TreeSet in Java and null acceptance in TreeSet?

TreeSet in Java and null acceptance in TreeSet?

  TreeSet in Java and null acceptance in TreeSet? The underlying data structure is the balanced tree. Duplicate objects are not allowed. Insertion order not preserved. Heterogeneous objects are not allowed otherwise we will get runtime exception saying ClassCastException. Null insertion possible (only once). TreeSet Implement Serializable and Cloneable but not . . . Read more

Difference between HashSet and LinkedHashSet?

Difference between HashSet and LinkedHashSet?

Difference between HashSet and LinkedHashSet? It is the child class of HashSet. A LinkedHashSet is an ordered version of HashSet that maintains a doubly-linked List across all elements. Contains unique elements only like HashSet. Provides all optional set operations, and permits null elements. Maintains insertion order. LinkedHashSet doesn’t have its . . . Read more