What is difference between ArrayList and LinkedList ?

Answer

Both the Array List and Linked List classes implement the List interface, but they differ on the following features:
An Array List is an index based data structure backed by an Array. It provides random access to its elements with a performance equal to O(1). On the other hand, a Linked List stores its data as list of elements and every element is linked to its previous and next element. In this case, the search operation for an element has execution time equal to O(n).
The Insertion, addition and removal operations of an element are faster in a Linked List compared to an Array List, because there is no need of resizing an array or updating the index when an element is added in some arbitrary position inside the collection.
A Linked List consumes more memory than an Array List, because every node in a Linked List stores two references, one for its previous element and one for its next element.

All Java Questions

Ask your interview questions on java

Write Your comment or Questions if you want the answers on java from java Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---