Linkedlist vs ArrayList implementation of List
Possible Duplicate:
When to use LinkedList<> over ArrayList<>?
What is the difference between these two list? they both implements the interface List
what in what case would you use a LinkedList above an ArrayList?
A classic interview question.
Read this: When to use LinkedList over ArrayList? or just google it, there is tonnes of information out there on this.
In day to day programming it is rare that you'd use LinkedList. However, you should definitley understand the differences.
If the frequency of adding and removing elements are greater, go for linked list.In arraylist, if you are removing an element from middle, the whole array after that element has to be moved to fill the vacant position.But in the case of linked list, each element will be having link to next element.So removing an element will require changing the pointer of its previous element to deleted element's next pointer.
But if you are looking for random access more, then go for arraylist...
链接地址: http://www.djcxy.com/p/19972.html上一篇: Java中基于索引的数据结构