CodesJava

Easy learning with example program codes

what is the difference between arraylist and linkedlist?


ArrayList:

ArrayList class extends AbstractList and implements the List interface. It uses dynamic arrays for storing elements. It maintains insertion order. ArrayList can contain duplicate elements. It is not synchronized.

Note: ArrayList provides the facility of random access because of it is index based.

LinkedList:

The LinkedList class extends AbstractSequentialList and implements the List and Deque interface. It uses linked list data structure to store elements. It can contain duplicate elements. It is not synchronized.

Note: It not provides the random access facility.

 

ArrayList LinkedList
It uses a dynamic array. It uses doubly linked list.
It is not efficient for manipulation because a lot of shifting is required. It is efficient for manipulation.
It is better to store and fetch data. It is better to manipulate data.

Java interview questions on collections



Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap