ArrayList and LinkList difference

Keywords: ArrayList, LinkList, HashMap

1, ArrayList advantage: Find high efficiency array elements.

2, LinkList advantages: high data efficiency deletions.

Implementation:

ArrayList underlayer is an array, according to subscript or quickly find elements traversing speed. The data deletions actually created a new array, so the low efficiency of additions and deletions.

LinkList bottom is a linked list, each of yard chain comprising (a chain of address) last, value (stored value), and next (next address chain). Want to find an element, you need to start from scratch to traverse, so look for low efficiency. And a movable long chain deletions next and last address of a next chain can be achieved, so that high efficiency deletions.

 

 3, HashMap bit: combines the advantages of both ArrayList and LinkList

Specific implementation: HashMap is a default length ArrayList array 16, where each element is stored in LinkList. When an object can know the index by 16%, the remainder hashcode method know, to find such a high efficiency.

Guess you like

Origin www.cnblogs.com/tudoukaoya/p/12153827.html