ArrayList and LinkedList differences in Java

Source: Internet
Author: User

The main difference between ArrayList and LinkedList is based on different data structures.

ArrayList is a data structure based on dynamic arrays , LinkedList based on the data structure of the linked list , the main differences from time complexity and space complexity are as follows:

1. Complexity of Time

For random access, ArrayList locates element positions quickly through an index, while LinkedList needs to find the elements in the list. So ArrayList faster than LinkedList.

For the Delete insert operation, ArrayList needs to reorder the arrays and reload all the data into a new array when the array is full, LinkedList just add an entry object. So LinkedList faster than ArrayList.

2. Complexity of space

LinkedList requires more memory because the location of each index of ArrayList is the actual data, and each node in LinkedList stores the actual data and the location of the front and back nodes

Reference:

http://pengcqu.iteye.com/blog/502676

Http://www.importnew.com/6629.html

ArrayList and LinkedList differences in Java

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.