ArrayList v/s LinkedList

Neha Shaikh
2 min readNov 23, 2019

Coming back with 4th blog on Data Structure which is about the new concept we interact in form of Collections in Java.I would mainly focus on ArrayList and LinkedList.

Both ArrayList and LinkedList are implementations of List interface so that both belongs to the same family.So if we want to work with LinkedList or ArrayList,the main agenda here to use this is you want to add values as for your desired requirements.

Now,

What is ArrayList?

ArrayList is a class that is found in java.util package.It is the part of Collection framework that implements List’s interface.As we know that we can not change the size of a simple Array but in ArrayList we can do so. So if we want to create a dynamic array and for this we use ArrayList to expand,compressed or anything we want to do with.It is implemented with the concept of Dynamic array.

Constructors:

ArrayList a=new ArrayList();

By default the capacity of ArrayList is ‘10’.If ArrayList reaches its maximum capacity then a new ArrayList object will be created with — New capacity=(Current capacity*3/2)+1;

What is LinkedList?

In linkedlist the elements are stored in contiguous locations where the next element contains the reference of the first element.It is implemented by Double LinkedList and it can contain duplicate elements.

Constructors:

LinkedList()

LinkedList(Collection c)

Methods:

void addFirst(Object o),void addLast(Object o),Object getFirst(),Object getLast(),Object removeFirst(),Object removeLast()

The fig. shown below shows the representation of both in memory.

Hope it might help….

--

--