ArrayList
is backed by array and LinkedList
backed Node's linked with refernece.
So operation on ArrayList
is actaully evalute operation on array. The add operation runs in amortized constant time, that is, adding n elements requires O(n)
time. All of the other operations run in linear time (roughly speaking). The constant factor is low compared to that for the LinkedList
implementation.
and on LinkedList
all of the operations perform as could be expected for a doubly-linked list. Operations that index into the list will traverse the list from the beginning or the end, whichever is closer to the specified index.
read more on documentation -