Learning about arrays

Source: Internet
Author: User
Tags array length

What is an array?

can store any number of data of the same type.

Declaration of the array: data type [] variable name;

Assignment of the array: variable name =new data type [length];

Merge writing: data type [] variable name =new data type [length];

The array must be the same as the type, and each array item has a number: called an index or subscript.

The index (subscript) of an array is a number of type int.

The index (subscript) starts at 0, and in turn is the number of each item in the array.

The default value of an array item: The value of an array item after it is created, and the default value for the array item type.

A numeric type with a default value of 0;

BOOL type, the default value is false;

Char type, default value is;

String type, the default value is null (empty meaning).

Reading of array items: variable name [index];

From the specified array, the value of an array item is fetched by number, and the return type is the same as the array item type.

Modification of array Item: variable name [index]= value;

Read array length: variable name. Length

Learning about arrays

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.