LinkedList in Java

LinkedList is not most commonly used class for storing the values. The LinkedList class extends AbstractSequentialList and implements the List interface. It stores the data using linked-list data structure. This class has two constructors,

With empty parameters – LinkedList() and

With Collection object as the parameter – LinkedList (Collection c)

Some of the important features of this class is:

It supports the duplicate elements insertion

Similar to ArrayList, it maintains the insertion order

LinkedList is not synchronized

It doesn’t support the random access for retrieving the values

It can be used as list, stack or queue.

One of the main drawback of using the linked list is that each element should have a pointer to the next and previous elements, It is extra overhead for each elements. This overhead is not with the ArrayList. The only time when LinkedList is better than ArrayList is that, when performing insertion or removal with the iterator which is more efficient than the ArrayList. In ArrayList every insertion or removal needs the copy of objects to new array.

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.

About Us

Javabeat.net is a blog dedicated to Java/J2EE developers. This site focus on beginners and advanced developers. We constantly write fresh content on J2EE topics like Spring, Hibernate and wide variety of J2EE frameworks.