以下代码给我带来了麻烦:
String more = "yes";
Scanner in = new Scanner(System.in);
while (more != "no") {
//do stuff
System.out.println("Want to add more? (yes or no)");
more = in.nextLine();
}
只要用户没有输入"否,"循环应该继续。问题是,当我输入no时,它仍然没有停止。