Java: 2-Dimensional Array
2-Dimensional Arrays
The syntax to declare 2-dimensional array is this TypeOrClass[][]
.
public class Ar2 { public static void main(String[] args) { // declaring that xx is a 2-dimensional array int[][] xx; // give the variable a value, and declare its dimensions. xx = new int[3][2]; // assign a value to a array slot xx[0][0] = 6; System.out.print(xx[0][0]); // prints the value of a slot System.out.println(); System.out.print(xx[0].length); // prints the length of a row } }