Web effects phttp://www.111cn.net/Web effects p.html target=_blank >jsp Tutorials ArrayList and LinkedList differences and characteristics of ArrayList
ArrayList)
Private transient object[] elementdata;
..........................................................................................
(LinkedList)
Private transient entry<e> Header = new entry<e> (null, NULL, NULL);/list Header
Internal linked list class.
private Static Class Entry<e> {
e element; Data elements
Entry<e> Next; Precursor
Entry<e> previous;//Rear Drive
Entry (e element, entry<e> Next, entry<e> previous) {
This.element = element;
This.next = Next;
This.previous = previous;
}
}
/*
No doubt, the 1th is that the internal data structure of the two is different, the ArrayList inner element container is an object array,
and LinkedList inside actually a list of data structure, it has an internal class to represent the linked list.
The different parent classes of the two determine the different storage forms of the two. ArrayList inherits from Abstractlist, and LinkedList inherits from Abstractsequentiallist. Both achieve the backbone of the list, only the former access to the form of "random Access" data storage (such as arrays), the latter tend to "continuous access" data storage (such as linked lists)
*/
Public
class Arraylist<e> extends abstractlist<e>
public class Linkedlist<e> extends abstractsequentiallist<e>
/*
Then there is the efficiency of both, ArrayList based on the array implementation, so there is no doubt can be directly indexed by subscript, its index data fast, insert elements designed to move the elements of the array, or array expansion, so the insertion element is slow. LinkedList based on the linked list structure, the insertion element only needs to change the insertion of the elements before and after the point, so the insertion of data quickly, and the index elements need to traverse backwards, so the index element is slow.
*/
public void ensurecapacity (int mincapacity) {
modcount++;
int oldcapacity = Elementdata.length;
if (Mincapacity > Oldcapacity) {
Object olddata[] = Elementdata;
Here the enlarged size is about 60% of the original size
int newcapacity = (oldcapacity * 3)/2 + 1;
if (Newcapacity < mincapacity)
newcapacity = mincapacity;
Creates a new array of the specified size to overwrite the original array
Elementdata = arrays.copyof (Elementdata, newcapacity);
}
}