Skip to content

Commit a06da14

Browse files
Two dimensional arrays
1 parent 0d8a6b3 commit a06da14

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

956 Bytes
Binary file not shown.

src/TheTwoDimensionalArrays.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import java.util.Arrays;
2+
3+
public class TheTwoDimensionalArrays {
4+
5+
public static void main(String[] args) {
6+
char[][] board = new char[3][3];
7+
8+
for (int i = 0; i < 3; i++) {
9+
for (int j = 0; j < 3; j++) {
10+
board[i][j] = '-';
11+
}
12+
}
13+
14+
board[0][0] = 'o';
15+
board[1][0] = 'o';
16+
board[2][0] = 'o';
17+
18+
System.out.println(Arrays.deepToString(board));
19+
20+
char[][] board2 = new char[][]{
21+
new char[]{'o', '-', '-'},
22+
new char[]{'o', '-', '-'},
23+
new char[]{'o', '-', '-'}
24+
};
25+
26+
System.out.println(Arrays.deepToString(board2));
27+
}
28+
}

0 commit comments

Comments
 (0)