public class TwoD { public static void main(String[] args) { char[][] a = { //or char a[][] = { {'O', 'O', 'X'}, {'X', 'X', 'X'}, {'O', ' ', 'O'} }; //top row System.out.print(a[0][0]); System.out.print(a[0][1]); System.out.println(a[0][2]); //middle row System.out.print(a[1][0]); System.out.print(a[1][1]); System.out.println(a[1][2]); //bottom row System.out.print(a[2][0]); System.out.print(a[2][1]); System.out.println(a[2][2]); System.out.println(); //skip a line for (int row = 0; row < a.length; ++row) { System.out.print(a[row][0]); System.out.print(a[row][1]); System.out.println(a[row][2]); } System.out.println(); for (int row = 0; row < a.length; ++row) { for (int col = 0; col < a[row].length; ++col) { System.out.print(a[row][col]); } System.out.println(); } //To initialize the two-dimensional array to all zeroes, //char[][] a = new char[3][3]; } }