Difference between ArrayList and LinkedList
ArrayList and LinkedList both implements List interface and so that both maintains insertion order. Both classes contains non synchronized methods.
However, there are many differences between ArrayList and LinkedList classes.
Use the below point to differentiate the concept behind these two data-structures
ArrayList | LinkedList |
---|---|
ArrayList internally uses dynamic array to store the elements | LinkedList internally uses doubly linked list to store the elements |
Insertions are not easy and fast in ArrayList as compared to LinkedList | Insertions are easy and fast in LinkedList as compared to ArrayList |
It act as a list only because it implements List only. | It act as a list and queue both because it implements List and Deque interfaces. |
ArrayList takes less memory since it store elements in contigious memory allocation by index holds actual object (data). | LinkedList has more memory overhead than ArrayList because LinkedList each node holds both data and address of next and previous node. |
O(n) time to find if an element is present or not and can search in O(Log n) time | O(n) time to find if an element is present or not and can search in O(Log n) time |
its better for storing and accessing data. | its is better for manipulating data. |