第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

第一章作業(yè)參考

參考作業(yè)的最后幾行中的“console = new Scanner(System.in);“的作用是什么,為什么刪掉后在輸入書(shū)本序號(hào)時(shí)輸入字母就會(huì)陷入死循環(huán)。

private static int inputCommand(){

int command;

try {

command = console.nextInt();

return command;

} catch (Exception e) {

//若輸入字符型或者字符串,則拋出異常,捕獲該異常,拋出”錯(cuò)誤命令異?!?/p>

console = new Scanner(System.in);

//返回-1

return -1;

}


正在回答

3 回答

我也遇到了這個(gè)問(wèn)題,刪掉

private static int inputCommand(){

int command;

try {

command = console.nextInt();

return command;

} catch (Exception e) {

//若輸入字符型或者字符串,則拋出異常,捕獲該異常,拋出”錯(cuò)誤命令異?!?/p>

console = new Scanner(System.in);

//返回-1

return -1;

}

這一段代碼,然后將主函數(shù)中的“int command =inputCommand();”改為:int command =

將“int index = inputCommand();”改為:int index = console.nextInt();

0 回復(fù) 有任何疑惑可以回復(fù)我~

這個(gè)應(yīng)該是當(dāng)你拋出異常了,直接還可以在控制臺(tái)進(jìn)行輸入,不然的話,程序就終結(jié)了。。。。

0 回復(fù) 有任何疑惑可以回復(fù)我~

你刪掉這里還可以輸入么,厲害。小白有點(diǎn)看不懂。

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

冷西風(fēng) 提問(wèn)者

是最后幾行的“console = new Scanner(System.in);”,不是前面主方法的“Scanner console = new Scanner(System.in);”
2016-04-19 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

第一章作業(yè)參考

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)