ArrayList is an implementation of a mutable array of list interfaces. Implements all optional list operations and includes all elements, including null values. This class also provides methods to manipulate the size of the array used internally to store the list.
ArrayList is achieved by:
For ArrayList, he implements the list interface, the underlying use of arrays to save all elements, the operation is basically an array of operations.
LinkedList implements the list interface, but it performs and inserts operations more efficiently than ArrayList, because it is based on a linked list and also determines that it is less than ArrayList in terms of random access .
In addition, Linkedlis provides methods that can be used as stacks, queues, and double-ended queues, in which the names differ from each other, so that they are more appropriate in a particular context. 、
ArrayList(Fast to access, slow to modify) the underlying use of array elements, the size of the array is self-increasing, (insert element, because the array capacity is not known, the array is copied to a new array,).
LinkedList (Fast check slow) is the bottom of the list, through the node directly connect elements, each node contains the reference of the front and back nodes and the values stored by the node,
When modifying, insert a new element, only need to modify the reference relationship of the front and back nodes,
But access is, to traverse the node to locate, so the access speed is slow.
The realization principle of ArrayList