Differences between the arraylist class and the array class

Source: Internet
Author: User
What is the difference between the arraylist class and the array class? arraylist is a complex version of the array class. The arraylist class provides some functions that are provided in most collections classes but not in the array class. 1array is located in the system namespace, while arraylist is located in the system. Collections namespace. 2 array capacity is fixed, and the arraylist capacity is automatically expanded as needed. If the value of the arraylist. Capacity attribute is changed, the memory quota element is automatically replicated. 3arraylist allows you to add, insert, or remove a range of elements. In array, only one element value can be obtained or set at a time. 4. You can use synchronized to easily create a synchronization version of arraylist. Array will keep it until the user achieves synchronization. 5arraylist provides a method to return read-only and fixed-size packages to a set, while array does not. 6. array provides some flexibility that arraylist does not have. 7. You can set the lower limit of array, but the lower limit of arraylist is always zero. 8 array can have multiple dimensions, while arraylist is always only one-dimensional 9. A specific type of array has better performance than arraylist because the elements of arraylist belong to the object type, therefore, boxing and unboxing are often generated when you store or retrieve value types.

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.