How to assign values to two dimensional array in Java?

To assign values to 2D array in Java, do this: array[index1][index2] = value.

Here's how you do it:

int[][] array = new int[3][10];

array[0][5] = 33;
array[1][9] = 44;
array[2][1] = 55;

// [0,  0, 0, 0, 0, 33, 0, 0, 0,  0]
// [0,  0, 0, 0, 0,  0, 0, 0, 0, 44]
// [0, 55, 0, 0, 0,  0, 0, 0, 0,  0]
System.out.println(java.util.Arrays.toString(array[0]));
System.out.println(java.util.Arrays.toString(array[1]));
System.out.println(java.util.Arrays.toString(array[2]));