Sometimes people ask me the difference between java.util.ArrayList, java.util.LinkedList and java.util.Vector.
Well, if it is important to you I will tell you the basic stuff about them:
ArrayList: It is an implementation of an array, simple as that.
LinkedList: It is an implementation of an doubly-linked list, attention, doubly-linked list, so each node is linked to the next node and linked to the previous node at the same time.
Vector: It is like an ArrayList, but it is synchronized.
So, add and remove are slower in ArrayList because it generates another array and copy values to it.
But LinkedList is slower in get and set methods, because you have to pass through the list to find the element.
But you can check more information about them at:
https://docs.oracle.com/javase/8/docs/api/java/util/ArrayList.html
https://docs.oracle.com/javase/8/docs/api/java/util/LinkedList.html
https://docs.oracle.com/javase/8/docs/api/java/util/Vector.html
And DZone written a post about it in https://dzone.com/articles/arraylist-vs-linkedlist-vs.
Leave a comment