void Menue{ void Menu()throws java.io.IOException{ char menu; String name; System.out.println("\t\t\t\t\tMENU"); System.out.println("1. Bioraphy"); System.out.println("2.Start game"); System.out.println(); System.out.print("Choose one: "); menu= (char) System.in.read(); swihch(menue){ case '1' : System.out.println ("......."); this.Menue; break; case '2' : .......... } 

I want the Menue method to run again after selecting 1. It is called, but I have no way to enter the char menu. Only System.out.prinln () is displayed; and then break;

 case '1' : System.out.println ("......."); this.Menue; break; 
  • this.Menu () method; - Vadim Marchenko
  • one
    Author, read a book about Java - user182055

1 answer 1

Look at the following code, adapt it to your needs.

 class Test { public static void main(String[] args) throws java.io.IOException { showMenu(); char n = '0'; while(n!='3') { n = (char)System.in.read(); switch(n) { case '1' : System.out.println("Select 1"); showMenu(); break; case '2' : System.out.println("Select 2"); showMenu(); break; } } } public static void showMenu() { System.out.println("1. Number one."); System.out.println("2. Number two."); System.out.println("3. Exit."); } } 

As for your code, it will not compile, so it’s too early to talk about the execution or non-execution of some method in your code.