I need to make a program that reads the keyboard names until the user types the word "end", and then prints the names typed in the order they were typed.
So far, I have tried to resolve this issue using ArrayList
, like this:
public class Exercicios {
public static void main(String[] args) {
ArrayList<String> nomes = new ArrayList<>();
while(!nomes.contains("fim")){
for(int i = 0; i < nomes.size();i++){
System.out.println("informes quantos dados desejar e digite 'fim' para finalizar");
nomes.add(nomes.get(i));
System.out.println(nomes.toString());
}
}
}
}
Remembering that pro compiler, no error has appeared, but no results appear. What could be happening?