Array (English array) is a powerful tool that allows you to work with a lot of data. Obviously, if you need to save, for example, 100 values somewhere in the process of running your code, then making the same number of variables for this is at least unreasonable. An array allows you to store a large number of values under one name and access them at the corresponding index. The concept of arrays is the cornerstone in learning a Java course for beginners. After all, they are the basis for many data structures.
Java , , , java array – . , , .
Java array , . .
Java array, , . Java . , , . . , . new, ( , ), , ( , ), , , , .
Java array 0. , 0, – 5. , , , . , . , , , .
Java
, . , . . . , .
, . . 5 . . . , . , , , (length). , for.
. . , , ? – , . Java . , , 2, 3 4 . :
intarr[][] = newint[3][];
, . arr :
arr[0] = new int[2];
arr[1] = new int[3];
arr[2] = newint[4];
0, , 2. 1 3, . .
java array
. .
jerseyNumber playerName.
:
int[][] arr = {
{1, 2, 3},
{4, 5, 6},
{7, 8, 9}
}
new , . Java .
Arrays
, Java, java.util Arrays, , . .
Java array :
- copyOf (, ) – . , «» (0, , null , ).
- copyOfRange (, , ) – , . , , .
- sort () – .
- fill (, ) – .
- binarySearch (, ) – , . , .
, Arrays. : Arrays.sort(arr).
, , Java , , , . , . , .
Array Java «» , .