Boa tarde, sou novo aqui, me desculpe qualquer coisa, mais gostaria da seguinte ajuda, eu fiz esse código:
public static void main(String[] args) {
int numero = 0;
while (numero <= 0) {
String str = "Número de candidatos:";
str = JOptionPane.showInputDialog(null, str);
if (str == null) {
System.exit(0);
}
numero = Integer.parseInt(str);
numero = numero - 1;
}
String str = "";
String candidatos[][] = new String[numero][2];
for (int i = 1; i <= candidatos.length; i++) {
while (true) {
str = "candidato " + i;
str = JOptionPane.showInputDialog(null, str);
if (str == null) {
break;
}
str = str.trim();
if (str.length() >= 2 && str.length() <= 50) {
candidatos[i - 1][0] = str;
break;
}
}
if (str == null) {
break;
}
while (true) {
char[] caracteres = new char[]{'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
String senha = "";
Random rdm = new Random();
for (int cont = 0; i <= 8; i++) {
senha += caracteres[rdm.nextInt(36)];
}candidatos[i - 1][1] = senha;
}
}
String resultado = "";
for (int i = 0; i <= candidatos.length; i++) {
for (int l = 0; l <= candidatos[i].length; l++) {
resultado = resultado + candidatos[i][l];
}
JOptionPane.showMessageDialog(null, resultado);
}
}
}
porém ele esta dando nessa parte “candidatos[i - 1][1] = senha;” quando eu rodo, alguém saberia de dizer pq? ou como arrumar?desde já mt obrigado

