public class ex1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Please enter a series of strings each followed by the enter key. When you'd like to end thr program simply type 'quit': \n");
Scanner scan = new Scanner(System.in);
ArrayList<String> inputList = new ArrayList<String>(); // creates a list to store user input
String input = scan.nextLine(); //takes the scanner input
while(input != "quit") { //makes sure its not equal to quit
//System.out.println(input);
inputList.add(input);
input = scan.nextLine();
}
scan.close();
System.out.println("The number of strings enetered was: " + inputList.size());
System.out.println("The strings you entered were as follows");
for (String i: inputList) {
System.out.println(i);
}
}} While avec un scanner satisfait jamais la condition
J'essaie d'utiliser le code précédent pour prendre une série d'entrées d'un utilisateur à l'aide de la touche entrée et si elles entrant quit je finis le programme. Cependant, la condition est jamais satisfait et la boucle while ne se termine jamais et je ne peux pas comprendre pourquoi