Java 使主方法重新启动/刷新

Java 使主方法重新启动/刷新,java,Java,到目前为止,我的代码是: import java.util.*; import java.util.Scanner.*; public class Project{ // The Main Method public static void main(String [] args){ // Creates the Main Method System.out.println("Name a Method (Stability, efficiency ..)"); // Asks t

到目前为止,我的代码是:

import java.util.*;
import java.util.Scanner.*;

public class Project{ // The Main Method
  public static void main(String [] args){ // Creates the Main Method
    System.out.println("Name a Method (Stability, efficiency ..)"); // Asks the user to select a method
    Scanner scan = new Scanner(System.in); // Creates the Scanner
    String splash = scan.nextLine(); // Transitions the user to the next line after choosing a method
    if(splash.equals("efficiency")) // If users chooses Efficiency then it goes to the Efficiency method
    {
      efficiency(); // Calls the Efficiency method
    }
    if(splash.equals("Stability")) // If user chooses Stability then it goes to the Stability Method
    {
      stable(); // Calls the Stability method
    }
      else // What happens if the input wasnt recognized 

    {
      System.out.println("I don't recognize this"); // what happens if an irrelevant method is chosen
    }
  }
}
我将如何使其能够代替:

else // What happens if the input wasnt recognized 
{
    System.out.println("I don't recognize this"); // what happens if an irrelevant method is chosen
}

它将刷新或重新启动主方法?

将代码包装在
while
循环中,当用户选择退出命令时,您将离开该循环:

public static void main(String [] args){

   while (true) {
       System.out.println("Name a Method (Stability, efficiency ..)");
       Scanner scan = new Scanner(System.in);
       String splash = scan.nextLine();
       if (splash.equals("exit")) {
          break;
       } // else if (splash.equals("efficiency")) ...
   } 

}

将代码包装在
while
循环中,当用户选择退出命令时,您将离开该循环:

public static void main(String [] args){

   while (true) {
       System.out.println("Name a Method (Stability, efficiency ..)");
       Scanner scan = new Scanner(System.in);
       String splash = scan.nextLine();
       if (splash.equals("exit")) {
          break;
       } // else if (splash.equals("efficiency")) ...
   } 

}

你能用正确的括号把它放在main方法中吗?我把括号弄混了你能用正确的括号把它放到主方法里吗?我把括号搞混了