你好堆垛机,
System.out.print("Enter your first name: ");
firstName = keyboard.nextLine();
if(firstName!="Mike"&&firstName!="mike"&&firstName!="Diane"&&firstName!="diane")
{
System.out.println("derp");
}
else
discount=true;
然而,这是结果:
Enter your first name: diane
derp
如果有人能告诉我我做错了什么,那将非常非常感谢你!
答案 0 :(得分:0)
public class Test{
public static void main(String[] args) {
System.out.print("Enter your first name: ");
Scanner keyboard = new Scanner(System.in);
String firstName = keyboard.nextLine();
if (!(firstName.equalsIgnoreCase("mike") || (firstName.equalsIgnoreCase("diane")))) {
System.out.println("derp");
} else
System.out.println("true");
}
}
<强>输出强>
Enter your first name: diane
true