ArrayList and LinkedList

Source: Internet
Author: User

ArrayList
ArrayList actually wraps an array object[], when instantiating a ArrayList, an array is instantiated, and when the object is added to the ArrayList, the size of the array changes accordingly. This leads to the following drawbacks:
Quick access You can then access each element without regard to performance issues by calling the get (i) method to access the array element labeled I.
Adding objects to them is slow when you create an array, you can't determine its capacity, so you have to do a lot of things in memory when you change the array.
The speed at which objects are manipulated is slow when you want to add an object to any of the two elements in the array, the array needs to move all subsequent objects.

LinkedList
LinkedList are implemented by connecting nodes directly to each other. Each node contains a reference to the previous node, a reference to the latter node, and a value stored by the node. When a new node is inserted, it is only necessary to modify the references of the nodes in which the relationship is maintained, as well as when the record is deleted. This leads to the following drawbacks:
The speed at which objects are manipulated is simply to change the connection, and the new node can be anywhere in memory
cannot be accessed immediately although there is a get () method, but this method is positioned by traversing the contact so slow.

To be blunt, sequential storage and chained storage in data structures

ArrayList and LinkedList

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.