Initial capacity and capacity allocation for ArrayList in Java

Source: Internet
Author: User

1, instantiate ArrayList when the default input size is 10, and if increased to 11 will not error, will automatically expand.

2. To get the value of the specified index, you must ensure that ArrayList has so many.

3. It is recommended to specify the known size when new ArrayList, saving the resources when the capacity is expanded. Note: The size of the specified ArrayList is still 0 when it gets size;

Reference:

Https://www.cnblogs.com/ShanHeDiao/p/4402030.html

http://blog.csdn.net/jdsjlzx/article/details/52675726

http://zhh9106.iteye.com/blog/2152419

Http://www.cnblogs.com/CherishFX/p/4725394.html

Initial capacity and capacity allocation for ArrayList 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.