Java Collection Hierarchy

The collection is a framework in java. It contains some of the most used classes which are present in the interfaces. Collection interface mainly has 3 child interfaces and these are as follows. Image Source 1. List It contains an order of all the objects. This interface also helps you to have a dynamic size of arrays according to the number of objects present. It is implemented by Vector, Stack, ArrayList, and LinkedList. Therefore we can create a list object

Read more

TreeSet Vs TreeMap in Java

TreeSet is an implementation class of NavigableSet. In a TreeSet, duplicate as well as heterogenous (values of different data types) values are not allowed. If you’re trying to insert heterogeneous objects then it displays a ClassCastException. If the tree set exists, then we can insert a null value, and if the treeset doesn’t exist then we cannot insert a null value in it. All versions of Java below 6.0 allows insertion of null value, but all other versions show Null

Read more

Java LinkedList Class

In this tutorial you will learn about Java LinkedList class. Linked list is a linear data structure that contains nodes. Node stores data and reference to the next node. Java provides us in built classes and methods for creating and handling of linked list. So using linked list in java so easy. Also Read: Java Singly Linked List Implementation Java LinkedList Class Hierarchy of this class is: Java.lang.object java.util.AbstarctCollection java.util.AbstractList java.util.AbstarctSequentialList java.util.LinkedList Now we see those built-in methods of this class.

Read more

Difference between Hashtable and HashMap in Java

Here you will learn about difference between Hashtable and HashMap in Java. Both Hashtable and HashMap are data-structure based upon hashing and implementation of Map interface, and almost seems to be similar but there is significant difference between both which is described as follows. Characteristic Hashtable HashMap Synchronization Hashtable is  synchronized internally. Synchronization means that merely one thread can change that Hashtable at one time. Fundamentally it signify that  Hashtable will have to attain a lock on the object prior

Read more

Difference between ArrayList and LinkedList in Java

Here you will learn about difference between arraylist and linkedlist in java i.e. arraylist vs linkedlist. Both ArrayList and LinkedList are similar in many ways like both implement List interface and are non-synchronized. But still there are various differences between them which I have discussed below. Also Read: Difference between ArrayList and Vector in Java Image Source Difference between ArrayList and LinkedList in Java ArrayList LinkedList Implementation ArrayList internally implements dynamic array to store elements. LinkedList internally implements doubly linked list

Read more

Difference between ArrayList and Vector in Java

Here you will get to know the difference between ArrayList and Vector in Java programming language. ArrayList It is a class in Java that implements List interface. Unlike traditional array data structure, it is not fixed in length and doesn’t require its size to be specified in order to declare it. They can grow and can be reduced dynamically as per need. Apart from these benefits ArrayList class has many pre-defined methods which could help the developers save a lot

Read more

Difference between Array and ArrayList in Java

Here you will learn about difference between array and arraylist in java. Both array and arraylist are most important and frequently used data structure in java. Below I have discussed about various differences between them.   Difference between Array and ArrayList in Java Property Array ArrayList Size Array is fixed in size. Once declared, its size can’t be changed. ArrayList size can be changed after declaration. For example when we add or remove element in arraylist, its size increases or

Read more

Comparable vs Comparator in Java

Here you will learn about Comparable vs Comparator in Java. Difference between Comparable and Comparator is one of the commonly asked questions in Java interviews. Both the interfaces are used to sort collection objects but still there are some differences between them which I have discussed below. Also Read: Comparable and Comparator Example Comparable vs Comparator in Java S.No Comparable Comparator 1. It is used to sort objects on the basis of only one property at a time. For example if

Read more
1 2