 
		krone
2016-08-05 17:18
public void goOn(int i){
System.out.println("是否继续查询?是:Y 否:N");
Scanner in=new Scanner(System.in);
String control=in.nextLine();
if(control.equals("Y")||control.equals("y")){
if(i==1)rentway1();
if(i==2)rentway2();
}
else library();
}
有更好的方法吗?
if(i==1)rentway1();
if(i==2)rentway2();
不同的方法跳转到的不同。。
 
							
				System.out.println("是否继续查找:Y是,N否");
				Scanner ccc =new Scanner(System.in);
				while(true){					
					String yes = ccc.nextLine();
				if (yes.equals("y")||yes.equals("Y")){
					show();//show()是整个程序最先运行的方法 也就是说返回重新开始
					break;
				}else if (yes.equalsIgnoreCase("N")||yes.equals("n")){
					System.out.println("感谢使用!");
					break;
				
				}else {
				System.out.println("输入错误请重新输入");
					continue;
				}
				}
			 
				可以直接用switch
switch(i){
case:1
rentway1();
break:
case2:2
rentway2();
break;
}
Java入门第三季
409776 学习 · 4546 问题
相似问题