Reputation: 75
I was doing a Tetris tutorial online, and noticed that there is an integer declared like this
int[][][] blah;
Why does the integer have those 3 brackets?
Upvotes: 0
Views: 144
Reputation: 3651
It is a 3-dimensional array as what has been said earlier.
You might want to start slow and understand what an array is before going into 3 dimensional. An array is declared as either one of the following ways. It can be used to hold a set of values of the same type (same type as in int, string and so on) instead of having to declare individual variables for each value.
int[] myArray = new int[5];
or
int[] myArray = {1,5,7,1,2};
Upvotes: 2
Reputation: 39355
It means its a three dimensional array. It can hold the values like:
[
[1,2] [4,5]
[2,3], [6,7],
]
At above, each values are integer.
[1,2]
is an array.
[1,2]
[2,3]
is a 2d array.
Upvotes: 2
Reputation: 2004
It's 3 dimensional array declaration. Such declarations are given because a[5] means something different in different dimensional arrays.So its a declaration to read the references properly.
Upvotes: 1
Reputation: 29776
It is a jagged array of integers - An array of arrays of arrays.
Upvotes: 1
Reputation: 180777
It is a three-dimensional array.
Each set of brackets corresponds to an axis. Retrieving a value within the three-dimensional space looks something like this:
int value = blah[x][y][z];
Further Reading
Multi-Dimensional Arrays in Java
Upvotes: 9