Use collections to organize related data

Source: Internet
Author: User

Introduction of Set Concept

Collection: Some specified sets of objects together are collections

The following is a collection of Hello Kitty

Arrays: Containers that can store a stack of data of the same data type

Limitations of arrays: because it is particularly troublesome to add elements to an array and delete elements, I would like to find a tool to replace the array to help us implement the functions that the array can achieve.

Advantages of the collection: 01. Automatic Expansion Many of the methods in the collection can make it easier to manipulate the data in the collection.

xx. using ArrayList first needs to introduce namespaces

Dynamic expansion principle of the set: if the number of elements in the collection is 0, there is no space to open

The default if the first element appears in the collection, the size of the collection is 4, and if you put the 5 element, it expands to 8 .

If you specify the length of the collection when you first define it in parentheses, the way you expand later

becomes 2 times the size of the first specified number , and if no length is specified, follow The code of the

The interior of the collection is also copied through two arrays , but Microsoft has optimized it, and we don't care about efficiency .

the concept of a collection

Automatic expansion:

Capcity and Count differences?

The constructor function .

Concept: Defines a method for a class with the same method name and class name, no return value, and no even void .

the non-generic collection before use, be sure to import the namespace first.

. Namespaces

Parsing: The ability to use all the content (classes, methods) under this namespace

Ensure that classes with the same name can appear under different namespaces.

Use collections to organize related data

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.