Differences between ArrayList and LinkedList can be summarized in following points:
ArrayListinternally uses a resizable-array implementation of the List interface to store the elements.LinkedListis doubly-linked list implementation of theListandDequeinterfaces.LinkedListimplementsDequeinterface as well, so it provides queue like FIFO functionality through methods such aspeek()andpoll().ArrayListcan be created as empty list of initial capacity 10 by overloaded constructor, whileLinkedListonly constructs the empty list without any initial capacity.- Manipulation with
ArrayListis slow in comparison toLinkedListbecause it internally uses an array. If any element is removed from the array, elements need to be shifted in memory. Manipulation withLinkedListis faster thanArrayListbecause it uses a doubly linked list. - Insertions are fast in
LinkedListas compared toArrayListbecause there is no need of resizing array and copying content to new array if array gets full. Adding n elements requires O(n) time in case ofArrayList.
While insertion operation inLinkedListrequires O(1).ArrayListalso needs to be update its index if you insert something anywhere except at the end of array. - Since
ArrayListis backed by array, search operation based on index is pretty fast compared to theLinkedListsearch operation.get(int index)inArrayListgives the performance of O(1) whileLinkedListperformance is O(n). - In
LinkedListeach element maintains two pointers (addresses) which points to the both neighbor elements in the list. Hence removal of element only requires change in the pointer location in the two neighbor nodes (elements) of the node which is going to be removed. While InArrayListall the elements need to be shifted to fill out the space created by removed element.LinkedListremove operation gives O(1) performance whileArrayListgives variable performance: O(n) in worst case (while removing first element) and O(1) in best case (while removing last element). ArrayListmaintains indexes and element data whileLinkedListmaintains element data and two pointers for neighbor nodes hence there is memory overhead associated withLinkedList.LinkedListcan be iterated in reverse direction usingdescendingIterator()while there is nodescendingIterator()inArrayList.
