Differences between Java ArrayList and rule list

Source: Internet
Author: User

Differences between Java ArrayList and rule list
ArrayList implements a dynamic array-based data structure. The ArrayList is based on the linked list data structure. 1. For ArrayList and sort list, the overhead of adding an element at the end of the list is fixed. For ArrayList, an item is mainly added to the internal array, pointing to the added element. Occasionally, the array may be re-allocated. For the sorted list, this overhead is uniform, allocate an internal Entry object. 2. inserting or deleting an element in the middle of the ArrayList means that all the remaining elements in the list will be moved. the overhead of inserting or deleting an element in the middle of the List is fixed. 3. the random list does not support efficient random element access. 4. the space waste of ArrayList is mainly reflected in the reserved capacity space at the end of the list. The space consumption of the list is reflected in that each of its elements consumes a considerable amount of space. You can say that: when the operation adds data to the end of a column of data rather than in the front or middle, and needs to randomly access the elements in the column, using ArrayList will provide better performance; when you add or delete data in front or middle of a column of data and access the elements in the column in sequence, you should use the sort list.

Related Article

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.