Answer to Question #48015 in Java | JSP | JSF for javabegin
How different between LinkedList and ArrayList ? In which case we use each of them LinkedList or ArrayList?
ArrayList is that former is backed by an array while later is based upon LinkedList linked list data structure. The performance of add(), remove(), contains() and iterator() different for both ArrayList and LinkedList. You should use LinkedList in Java if: • Your application can live without random access. Because if you need n-th element in LinkedList you need to first traverse up to n-th element O(n) and than you get data from that node. • Your application is more insertion and deletion driver and you insert or remove more than retrieval. Since insertion or removal doesn't involve resizing its much faster than ArrayList.