- List collection: providing a number of "the index" to deposit, Methods elements. List Because the index to access the elements, so that a plurality of elements set traversal methods.
import java.util.ArrayList; import java.util.List; public class ListTest { public static void main(String[] args) { List<String> list = new ArrayList<String>(); list.add("孙悟空0"); System.out.println(list); list.add("沙和尚0"); System.out.println(list); list.add(1,"孙悟空1"); System.out.println(list); list.add(2,"沙和尚1"); System.out.println(list); } }
- Storage mechanism ArrayList and the Vector: entirely based on both the underlying array - for storing data, based entirely on the array, so the performance is very fast, when inserting and removing elements, all the elements behind to follow "the whole move."
- The difference between ArrayList and the Vector: vector collection there is a JDK1.0, from after JDK1.2, sun rewrite designed ArryList, instead of the original vector. ArrayList thread is unsafe, vector thread safe. ArrayList better performance than vector, in the case of multi-threaded and can use the ArrayList Collections converted into a thread-safe.
- LinkList: i.e. a linear form, and a queue, a stack, and, based on the underlying list achieved, the performance is generally slower than that ArrayList. When the insert elements, remove elements without "overall move", so performance is very fast.