【发布时间】:2018-06-23 09:42:11
【问题描述】:
我有一个程序,用户应该能够在其中输入多少度数和刻度(摄氏度、华氏度或开尔文)。如果用户希望退出会话,程序应该退出,如果他们写“Exit, EXIT, exit, QUIT, Quit or quit”。我知道如何一次只使用其中一个来编写代码,例如:
System.out.println("Enter your value, followed by the unit (C/F/K) : ");
temp=input.nextLine();
if (temp.contains("exit")) {
System.out.println("Ending");
System.exit(0);
}
我希望能够编写如下内容: if (temp.containsIgnoreCase("exit" || "quit") )
谁能帮助我提供一些关于如何修复我的代码的指南?我试图在这里搜索它,但没有任何效果,只有当括号内有两个不同的单词时才会出错。
【问题讨论】:
标签: java string contains ignore-case