Have a Question?

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

Tag: Collection interview question

What is IdentityHashMap?

What is IdentityHashMap? In journal == operator meant for reference comparison (address comparison) and equals() method meant for content comparison. It is exactly same as HashMap(including methods and constructors) except the following difference. In the case of normal HashMap, JVM will use .equals() method to identify duplicates keys, which is meant for content . . . Read more

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? 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

HashSet in Java and what is FillRatio or LoadFactor?

HashSet in Java and what is FillRatio or LoadFactor? The underlying data-structure is Hashtable. Duplicate objects are not allowed. Insertion order is not preserved and it is based on HashCode of objects. Null insertion is possible (only once). Heterogeneous objects are allowed. Implements serializable and cloneable but not the RandomAccess interface. . . . Read more