I am trying to create a simple Scanner test program which will exit once the user inputs "Quit".
I have the variable being output to console and it will output Quit but when I am trying to compare the variable to the raw string it doesn't see it as true.
public static void main(String[] args) {
String input;
Scanner sc;
System.out.println("Enter 'Quit' to exit.");
while (true) {
sc = new Scanner(System.in);
input = sc.nextLine();
if (input == "Quit") {
break;
}
System.out.println(input);
}
sc.close();
}