Have a Question?

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

Month: June 2018

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

Difference between ArrayList and LinkedList in Java?

  Difference between ArrayList and LinkedList in Java? The underlying data structure is double LinkedList. Insertion order is preserved. Duplicate objects are allowed. Heterogeneous object allowed. Null insertion is possible. LinkedList implements Serializable and Cloneable interface but not RandomAccess LinkedList is the best choice if our frequent operation is insertion . . . Read more

Explain ArrayList and difference between ArrayList and Vector?

Explain ArrayList and difference between ArrayList and Vector? ArrayList is a class, that uses a dynamic array for storing the elements. It extends AbstractList class and implements List interface. The underlying data structure is a Resizable array or growable array. Duplicates are allowed. Insertion order is preserved. Heterogeneous objects are . . . Read more