Some notes on understanding the use of arrays in Java

Source: Internet
Author: User

1. Array elements are variables;

2. With square brackets [] After the existing data type, a new array type is generated;

Divided into two categories: 1) Basic data types, such as: int[],string[];

2) Reference data type, such as: person[] (Class);

The variables declared by the 3.main method are local variables, which are stored in the stack;

4. Array elements, as part of an array object, are always stored in heap memory, whether they are primitive data types or array elements of reference data types;

5. When accessing an instance property by referencing a variable or calling a non-static method, if the reference variable has not yet referenced a valid object (that is, unallocated memory space), the program throws a nullpointerexception run-time exception (runtime exception);

6.Cats is a custom class, cats as a cat[] array, is an array reference type; cats][0],cats][1] as an array element, is part of an array object;

Some notes on understanding the use of arrays in Java

Related Article

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: 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.