for each loop for 2d array code example
Example 1: reading a 2d array with for each loop
for (int[] u: uu) {
for (int elem: u) {
// Your individual element
}
}
Example 2: how to use loop in 2d array
for (int row = 0; row < board.length; row++) {
for (int col = 0; col < board[row].length; col++) {
board[row][col] = row * col;
}
}