A one dimensional array is an array for which you have to give a single argument (called index) to access a specific value.
E.G. with the following one dimensional array
array = [0,1,2,9,6,5,8]
The array at index 1 has the value 1. The array at index 3 has value 9. If you want to update the 3rd value to 8 in the array, you should do
array[2] = 8
A two-dimensional array is simply an array of arrays. So, you have to give two arguments to access a single value.
two_dim_array = [[1,2,3],[4,5,6],[7,8,9]]
If you want to update the 'second' value, you have to do
two_dim_array[0][1] = 'something'
That is because two_dim_array[0] is a one-dimensional array, and you still have to specify an index to access a value.
From now on, you can keep going deeper with the same reasoning. As any further dimension is another level in the list. So a three dimensional array would be :
3d_array =
[
[
[1,2,3,4],
[5,6,7,8]
],
[
[9,10,11,12],
[13,14,15,16]
]
]
Now to access a value you have to give .. 3 parameters. Because
3d_array[0] // is a two-dim array
3d_array[0][1] // is a one-dim array
3d_array[0][1][0] // is a value
I suggest you start doing simple exercices to get you familiar with this concept, as it is really 101 programming stuff. W3resource has great exercices to get you started.
To declare a two-dimensional array, you simply list two sets of empty brackets, like this:
int numbers[][];
Here, numbers is a two-dimensional array of type int. To put it another way, numbers is an array of int arrays.
Often, nested for loops are used to process the elements of a two-dimensional array, as in this example:
for (int x = 0; x < 10; x++)
{
for (int y = 0; y < 10; y++)
{
numbers[x][y] = (int)(Math.random() * 100) + 1
}
}
To declare an array with more than two dimensions, you just specify as many sets of empty brackets as you need. For example:
int[][][] threeD = new int[3][3][3];
Here, a three-dimensional array is created, with each dimension having three elements. You can think of this array as a cube. Each element requires three indexes to Access.
You can nest initializers as deep as necessary, too. For example:
int[][][] threeD =
{ { {1, 2, 3}, { 4, 5, 6}, { 7, 8, 9} },
{ {10, 11, 12}, {13, 14, 15}, {16, 17, 18} },
{ {19, 20, 21}, {22, 23, 24}, {25, 26, 27} } };