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 entries in addition to an underlying array of default size ...

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). Null is allowed for values(Any numbers of times). HashMap implements ...

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 can insert an element. You cannot access elements by their ...

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. compareTo();   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 if we are not satisfied with natural sorting order then ...

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 RandomAccess Interface. All objects will be inserted based on some ...

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 own methods. All methods are inherited from its superclass i.e ...

Read More »

Responsive WordPress Theme Freetheme wordpress magazine responsive freetheme wordpress news responsive freeWORDPRESS PLUGIN PREMIUM FREEDownload theme free