package c1;
import java.util.Scanner;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
Test t=new Test();
t.selection();
}
public void selection(){
System.out.println("please input [Y] or [N]");
Scanner scanner = new Scanner(System.in);
String str=scanner.nextLine();
if(str.equalsIgnoreCase("Y")||str.equalsIgnoreCase("N")){
System.out.println("your selection is correct;");
}
else{
System.out.println("your selection is incorrect;");
selection();
//return; //you need add a return here if you have to add more codes in below
}
//System.out.println("here will be excuted twice or more times;");//这里不应该再有语句,否则在用户输入错误的情况下,可能会执行多次,除非在上面加了return语句。
}
}
阅读(365) | 评论(0) | 转发(0) |