Java Array Learning

Source: Internet
Author: User

1. Static characteristics of the Java array:

Java is a static language, and the length of an array in Java is fixed. Also, the type of the array element is specified when it is defined.

2. Keywords in the Java array:

Array variable: a reference variable, but the type of the reference is an array type. The array type is peculiar and does not require programmers to design the properties and methods of the class, as long as a known reference type (class, interface, and array) is added with a [], the JVM automatically generates such a new type.

As a variable, it is present in the stack space. However, because it is a reference variable, the content that it points to (the saved value) is in the heap space.

Array object: Saves the contents of the sub-heap space, is the same type of objects, stored together centrally.

Array elements: The variables referenced by the array subscript, remembering the first address (array name) saved in the stack space, while the array element is pointing dynamically.

3. Initialization mechanism for Java arrays:

Java array initialization is divided into two types:

Static initialization, specifying its value directly at the time of definition, the JVM automatically calculates other properties such as its length.

Dynamic initialization, definition and assignment are two steps. However, at this point in the definition, you need to specify its length.

The initialization of reference variables in Java is the concept of heap memory, that is, the initialization of objects in heap memory.

Otherwise this initialization is still in the stack memory concept, object type assignment null, native type assignment 0,0.0, false and so on.

4. The multidimensional array concept of Java:

There is actually no such entity in Java as a multidimensional array. In the C language, a multidimensional array takes precedence over a row, and then stores all the elements centrally. But in Java, at the storage level, there is only one-dimensional array concept. For example, int[][][], the top-level array of one-dimensional arrays element type is int[][], that is, a reference. What this looks like is the combination of arrays and linked lists.

Reference

1. "Crazy Java, 16 lessons from the fundamentals of Programmers" Li Gang.

Java Array Learning

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.