How can i break out this while loop? i want it to break it out when i type "finish." But it dose not seems to work.
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;
}
}
}
}