declaration |
String chessboard [ ] [ ]; int tictactoe [] []; |
declaration-initialization |
int x [] [] [] ={ 3 row } { { } , { } , { } } {3 row, 2 column} { { {},{} } , { {},{} } , { {},{} } } {3 row, 2 column, 4 numbers} { { {5,5,5,5},{5,5,5,5} } , { {7,7,7,7},{7,7,7,7} } , { {8,8,8,8},{8,8,8,8} } } |
char array |
char tictactoe [] []= {{‘ ‘,’ ‘,’ ‘},{‘ ‘,’ ‘,’ ‘},{‘ ‘,’ ‘,’ ‘}}; careful: ‘ ‘ not " " add ; in the end |
creation |
chessboard=new String[8][8]; not String chessboard[] []= new String [8][8]; because chessboard has been declared. |
tictactoe has been declared to be a two-dimensional array of integers. |
tictactoe= new int [3][3]; |
Declare and instantiate a 3×3 two-dimensional array of integers named tictactoe |
int tictactoe[] []= new int [3][3]; |
element access |
tictactoe [0][0] row position 0 1 2 …. column position 0 1 2 3 …. |
an expression show the elements of the first row are all equal |
tictactoe[0][0]==tictactoe[0][1] && tictactoe[0][0]==tictactoe[0][2] |
show 3 row, 3 column, |
draw a picture to see the position don’t make mistake 0 1 2 0 00 01 02 1 10 11 12 2 20 21 22 |
two-dimensional arrays
Share This
Unfinished tasks keep piling up?
Let us complete them for you. Quickly and professionally.
Check Price