Arraylist vs LinkedList Java

ArrayList Vs LinkedList:

ArrayList:
1. Search operation is faster, because it maintains the array structure, so get(index) will search and give the value fastly.
2. Less memory consumption because it maintains element and data. Where in linkedlist it maintains two pointer to store the addresses of the neighbour elements.

LinkedList:
1. Remove operation is faster.
2. Insertion operation is faster.
Because it is doubly linked list, so maintains both the address, where as in arraylist it need to shift the deleted area with the neighbour values.

When to use ArrayList:
Arraylist is recommended if we use search operation more. (get(index) function).

When to use LinkedList:
LinkedList is recommended if we use add/remove operations more. (add() and remove() function).

Recommended Books:

Leave a Reply