Have a Question?

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

Tag: core java interview question

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