如何防止执行另一个方法

时间:2018-03-03 07:51:47

标签: java

public class object{

public static void method1() {

   System.out.println("Go to Another method? [y] yes [n] no");
   choice = scan.next();

// If I choose "y" it keeps going to ifChoiceNo method
// how prevent this from happening

   if (choice.equalsIgnoreCase("y")) {

       object.ifChoiceYes();
   }

   if (choice.equalsIgnoreCse("n")) {

      object.ifChoiceNo();
   }  


}
public static void ifChoiceYes() {

System.out.println("Your Choice is Yes");

}



public static void ifChoiceNo() {

System.out.println("Your Choice is No");

}

0 个答案:

没有答案