I've a problem when convert a 2D arrays into an integer using "for each" loop
import java.util.Scanner;
public class matrix{ public static void main(String[] args) {
Scanner userInput = new Scanner(System.in);
int [][] matrix = new int[2][2];
for (int x = 0 ; x < 2 ; x++){
for(int y = 0 ; y < 2 ; y++){
System.out.printf("enter a number for row %d column %d : ",(x+1),(y+1));
matrix[x][y] = userInput.nextInt();
}
}
for(int t : matrix){
System.out.print(t + " ");
}
userInput.close();
}
}
Yet I get an error int[] cannot be converted to int.