Evening!
Guys, after the first loop, where the program asks for the names to be placed inside the Array, the second "for" is executing all of its functions without me giving it the permissions nor asking, it should've stood still till I gave him the name I'm looking for.
In a Nutshell, the code's returning "NAME NOT FOUND" without me even giving it a name to search for, (error happens only once though).
Best Regards,
Rangel Lipe
Here's the code:
package matrizes; import java.util.Scanner; public class slide { public static void main(String[] args) { //VAR String[] nomes = new String[5]; Scanner ler = new Scanner(System.in); String entrada; String encerrar = "ENCERRAR" ; //INDEX for (int i = 0; i < nomes.length; i++) { System.out.println("Digite o nome do "+(i+1)+ "° aluno "); nomes[i] = ler.next(); } for(int i = 100; i >= 100;i++) { System.out.println("Digite o nome que queira verificar"); System.out.println("Ou ENCERRAR para encerrar o programa."); entrada = ler.nextLine(); if (entrada.equalsIgnoreCase(encerrar)) { entrada = "END"; System.out.println("Programa interrompido com sucesso !"); break; } else { for(int b = 0; b < nomes.length; b++) { if (entrada.equalsIgnoreCase(nomes[b])) { System.out.println("Nome encontrado !"); System.out.println(nomes[b]+" é nosso "+(b+1)+"° aluno !"); entrada = "true"; } } if (entrada != "true") { System.out.println("Nome não encontrado !"); entrada = "false"; } else { entrada = "false"; } } } ler.close(); } }