0

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;
            }

        }


    }


}
pcs
  • 1,864
  • 4
  • 25
  • 49
Mebighobo
  • 13
  • 1
  • 1
  • 7

0 Answers0