Java array definition (declaration) method

April 3, 2018

The way to define (declare) an array:

    Currently the java language supports two syntax formats:

        type[] arrayName;

        type arrayName[];

    Example:

int[] myList;
int myList[];

ps: 0. These two definitions are usually recommended to use the first format, because arrays (for example: int[]) are also a reference data type, so the first format not only has better semantics, but also has better readability;

        1. An array can only store data of one data type, but not data of multiple data types in the village;

        2. When defining an array value, only one reference variable is defined. This reference variable does not only want any valid memory, so the array cannot be used, and must be initialized before it can be used;

        3. When defining an array, the length of the array cannot be specified.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324136165&siteId=291194637