一、ArrayList
ArrayList can handle is a variable length array type, here not limited to "number" group, ArrayList is a generic class, can hold any type of object. As the name implies, it is an array ArrayList list, so its internal use is an array to store the object, because the Object is the parent class of all types, and therefore there is a ArrayList internal array of type Object class object stored. Commonly used methods are ArrayList class add (), clear (), get (), indexOf (), remove (), sort (), toArray (), toString (), etc., while a private ArrayList internal class that implements the interface Iterator , so you can use the iterator () method to get ArrayList iterator, at the same time, there is a private class implements ListIterator interface, ArrayList can also call listIterator () method to get ListIterator iterators.
Since ArrayList rely array to store objects, but packaging it up, so look for the efficiency of some of its methods is O (n), with almost ordinary array efficiency, but this is an ArrayList variable "array" and you can store all the specified object.
In addition, since all ArrayList methods are carried out by default in a single thread, so ArrayList is not thread safe. If you want to use in a multi-threaded, you should use the static method synchronizedList Colletions class () for ArrayList to call.
Two, LinkedList
LinkedList can see as a doubly linked list, all operations can be considered to be a doubly linked list of operations because it implements the Deque interface and the List interface. Similarly, LinkedList is thread safe, if you use it in a concurrent environment, the same static method synchronizedList Colletions class () can be called for LinkedList.
LinkedList implemented internally in, but not with normal array to store data, but the use of the node
Therefore, the maximum difference between LinkedList and ArrayList are LinkedList more flexible and efficient part of the method is much more efficient than ArrayList corresponding method, for the case where the data frequented, and requires the operator to be flexible enough to recommend LinkedList; For array changes small, mainly used to query the case, you can use ArrayList.