package javaapplication1;
/**
*
* @author joaosavio
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int[] x = {5,6,9,8};
int[][] y = {{1,2,3},{4,5},{6,7,8}};
for (int i : x) {
System.out.println(x[i]);
}
for(int i[]: y) {
for(int j: i) {
System.out.println(); //????????????
}
}
}
}
Pq quando vou imprimir o x[i] ta dando
“Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 5”
E o que coloco dentro do segundo loop para conseguir imprimir a matriz?
Abraços