Current location - Recipe Complete Network - Complete cookbook - In Java programming, returning from a submenu to the main menu means first outputting a menu of 1 and 2 and then entering 1 to enter a menu. How can I return to the previous menu?
In Java programming, returning from a submenu to the main menu means first outputting a menu of 1 and 2 and then entering 1 to enter a menu. How can I return to the previous menu?

Written before, please refer to:

public void submenu() {

menu();

int n = sc .nextInt();

while (n != 0) {

switch (n) {

case 1:

addDvd ("D:/dvd.txt");

break;

case 2:

deleteDvd("D:/dvd.txt");< /p>

break;

case 3:

queryDvd("D:/dvd.txt");

break;

default:

break;

}

menu();

n = sc.nextInt();

p>

}

}

private void menu() {

System.out.println("Enter dvd management interface");

p>

System.out.println("1. Add dvd");

System.out.println("2. Delete dvd");

System.out .println("3. Search dvd");

System.out.println("Please select an operation, ending with 0:");

}