Java LinkedList vs ArrayList Class

Category: Java   Tags: Java, Java Collection, Java ArrayList Class, Java LinkedList Class

Before going to the difference, you can go through Java ArrayList Class and Java LinkedList Class in details.

1.

ArrayList: Manipulation with ArrayList is slow because it internally uses array. On every manipulation array must be resized and copied.

LinkedList: Manipulation with LinkedList is faster than ArrayList because it uses doubly linked list.

2.

ArrayList: ArrayList is better for storing and accessing data. get(int index) is O(1).

LinkedList: LinkedList is better for manipulating data. add(E element) is O(1) and remove(int index) is O(n/4).