|
Answer» In Java collections FRAMEWORK ArrayList and LinkedList are TWO different implementations of List INTERFACE
- LinkedList is implemented using a doubly linked list concept where as ArrayList internally uses an array of Objects which can be RESIZED dynamically
- For LinkedList add(e Element) is always O(1) where as for ArrayList add(e Element) operation runs in amortized constant time, that is, adding n elements requires O(n) time.
- For LinkedList get(INT index) is O(n) where as for ArrayList get(int index) is O(1).
- If you are removing using the remove(int index) method then for LinkedList class it will be O(n). In case of ArrayList getting to that index is fast but removing will mean shuffling the remaining elements to fill the gap created by the removed element with in the underlying array.
In Java collections framework ArrayList and LinkedList are two different implementations of List interface
|