我希望在输入时终止我的程序5.
按下5时我的程序没有关闭.
代码段:
System.out.println("What do you want to do?");
System.out.println("1. Go north");
System.out.println("2. Go east");
System.out.println("3. Go south");
System.out.println("4. Go west");
System.out.println("5. Quit");
System.out.print("Enter command (1-5): ");
// get and return the user's selection
System.exit(0); // exit the menu
return s.nextInt();
Run Code Online (Sandbox Code Playgroud)
如何更改任何建议?