The difference between ArrayList, linkedlist and vectors

Source: Internet
Author: User

1. Inheritance relationship of ArrayList class

2. Inheritance relationship of LinkedList class

3. Vector Inheritance Relationship

4. Comparison of three

ArrayList LinkedList Vector

1, bottom is array Implementation, essentially is a array , increase the deletion slow, query fast;

2, , out of sync;

3, implementing variable size array, allowing null elements;

4, the default initial capacity is small, the estimated allocation amount, the allocation of a larger capacity can reduce the cost of resizing;

5, a variable-size array, When more elements want to be added to the ArrayList, their size will grow dynamically, but this will bring overhead. Internal elements can be accessed through get and set;

1, bottom linked list

thread unsafe ,

Queue interface;

4, add and remove Element has better performance than ArrayList, the query is weaker than ArrayList;

1. The bottom layer is realized by array ;

2, thread safety , synchronization;

3, low performance ;

4, Vector and ArrayList request more space when more elements are added, vector request double , ArrayList request size growth 50%;

All implemented the list interface

The difference between ArrayList, linkedlist and vectors

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.