我在这里有我的代码,我正在尝试检查用户是否输入 Y 或 N 来访问 switch 语句,但是即使我写 Y 或 N 它也会给我错误消息,我做错了什么?提前致谢
public void anotherAction() throws IOException{
System.out.println();
System.out.println("Would you like to perform an additional action? 'Y' or 'N'");
while(!reader.hasNextLine()){
System.out.println("Enter either 'Y' or 'N'");
}
String response =reader.nextLine().toUpperCase();
while(response != "Y" || response != "N"){
System.out.println("Enter 'Y' or 'N'");
response = reader.nextLine();
continue;
}
switch(response){
case "Y":
cc.getCommand(this.makeOption());
break;
case "N":
System.out.println("Exiting System...");
break;
}
}