關(guān)于return的疑問
public int BookSlect(){
try{
System.out.println("輸入命令:1-按照名稱查找圖書;2-按照序號(hào)查找圖書");
int num=input.nextInt();
if(num==1)
return 1;
if(num==2)
return 2;
}catch(InputMismatchException e){
System.out.println("命令輸入錯(cuò)誤!請(qǐng)根據(jù)提示輸入數(shù)字命令!");
return 0;
}
}
為什么在MyEclipse中編寫的時(shí)候會(huì)提示This?method?must?return?a?result?of?type?int,語句中不是有return了 跪求大神解答啊!快暈了
2015-08-24
因?yàn)槟愕膔eturn語句并不一定執(zhí)行啊
2016-05-31
現(xiàn)在就可以看出來finally的重要性了
2015-10-16
。。為什么不會(huì)執(zhí)行啊,三種情況不是都有return嗎