将字符串与输入表单用户进行比较。JAVA
下面是一段代码
System.out.println("How would you describe your lifestyle? Sedentary, Somewhat Active, Active, Highly Active?");
String lifestyle = keyboard.next();
if (lifestyle.equalsIgnoreCase("Somewhat Active"))
{
System.out.println("ok");
}
else
{
System.out.println("not ok")
}
无论我输入什么,我都无法得到“ok”的回复
# 1 楼答案
你应该按照hexafraction的建议试试
nextLine()