Pessoal, estou populando 2 vetores, com o nome e o código das atividades cadastradas (vetorAtividades e vetorDados), após isso, inicializo uma matriz contendo estes 2 vetores. Porém no laço onde estou mostrando minha matriz, está retornando um erro…
Segue abaixo o método, e após esse, o erro:
public static void main(String args[]) {
AtividadeCon atividadeCon = new AtividadeCon();
String[] vetorAtividades = new String[]{};
String[] vetorDados = new String[]{};
int cont = 0;
for (Atividade a : atividadeCon.getAtividades()) {
vetorAtividades[cont] = a.getDescAtividade();
vetorDados[cont] = String.valueOf(a.getCdAtividade());
cont++;
}
String[][] matriz = new String[][]{vetorAtividades, vetorDados};
// Mostra a Matriz
for (int i = 0; i < matriz.length; i++) {
for (int j = 0; j < matriz[i].length; j++) {
System.out.println("" + i + "-" + j + "" + matriz[i][j]);
}
}
}
ERRO:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at Teste.main(Teste.java:30)
Java Result: 1
Agradeço desde já…