I cant see difference Arraylist and Linkedlist | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I cant see difference Arraylist and Linkedlist

In the example above, there is no difference between Arraylist and Linkedlist.

27th Aug 2020, 4:44 PM
Tugsu
Tugsu - avatar
1 Answer
+ 1
It looks like you're referring to Java's java.util.LinkedList and java.util.ArrayList. Internal structure and performance of different operations are the main differences. Both have very similar methods since both implement all methods of the List interface. ArrayList's get method will perform much better for a random index than LinkedList's get. ArrayList should perform get in O(1) time while LinkedList should average O(n). ArrayList's remove method will perform far worse than LinkedList's remove if you're removing from index 0 or near the beginning. Run an experiment to see for yourself. Test with lists of a million elements or more to make the performance differences easier to measure. More details can be found at: https://www.javatpoint.com/difference-between-arraylist-and-linkedlist
27th Aug 2020, 6:35 PM
Josh Greig
Josh Greig - avatar