「stop」と入力した後、コードが終了しません - 何らかの理由で。なんで?ステップバイステップのデバッグは、「stop」を入力した後、値が改行などなしで正確に「s」、「t」、「o」、「p」で構成されていることを示しています - ただし、コードはまだ実行されません出口。理由を教えてください。
import java.util.Scanner;
public class Application {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
// asking username
System.out.print("Username: ");
String username = input.nextLine();
String inpText;
do {
System.out.print(username + "$: ");
inpText = input.nextLine();
System.out.print("\n");
// analyzing
switch (inpText) {
case "start":
System.out.println("> Machine started!");
break;
case "stop":
System.out.println("> Stopped!");
break;
default:
System.out.println("> Command not recognized");
}
} while (inpText != "stop");
System.out.println("Bye!..");
}
}