Do while loop not working? (Cannot find variable)

前端 未结 3 417
借酒劲吻你
借酒劲吻你 2021-01-29 08:43

I am having trouble with my do while loop not finding my variable to test if the condition is true or not. Here is my code:

import java.util.Scanner;
public clas         


        
3条回答
  •  感动是毒
    2021-01-29 09:09

    Instead of declaring the play as a local variable declare it as a class level variable.

    String play;
    do {
        ...
        play = prompt.next();
    } while(play.equalsIgnoreCase("yes"));
    

提交回复
热议问题