我如何在循环中突破这个?当我输入“完成”时,我希望它能够突破它。但它似乎不起作用。
public class Main {
public static void main(String[] args) throws IOException {
PlayerReader r = new PlayerReader();
PlayerWrite w = new PlayerWrite();
r.Check();
System.out.println("Welcome, Please type enter or type finish to store information");
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
String cond = "finish";
while(str != cond)
{
w.writeName();
w.writeScore();
if(str == cond)
{
System.out.println("Information stored");
sc.close();
break;
}
}
}
}