Similarities and differences between array and arraylist

Source: Internet
Author: User

Similarities and differences between array and arraylist


1. Differences:

(1) arrayOnly homogeneous objects can be stored,

ArraylistHeterogeneous objects can be stored

(2) In the storage method of the CLR hosting pair, array isIt is stored continuously.,

ArraylistNot necessarily continuous Storage

(3) array-type variablesIt must be instantiated at the same time of declaration

ArraylistYou can just declare

(4) array objectOnly the specified size is required for initialization, and the size of the created array is fixed.;

ArraylistThe size can be dynamically specified. The size can be specified during initialization or not.

(5) arrayItems cannot be added or deleted at will.

ArraylistYou can insert or delete items anywhere.


2. Similarities

(1) can enumerate itself

(2) All created objects are stored in the managed stack.

(3) All have indexes, that is, you can use indexes to directly obtain and modify any items.

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.