異常catch疑問
private static int inputCommand(){
int command;
try {
command = console.nextInt();
return command;
} catch (Exception e) {
//若輸入字符型或者字符串,則拋出異常,捕獲該異常,拋出”錯誤命令異?!?/p>
console = new Scanner(System.in);
//返回-1
return -1;
請問加下劃線的語句是什么意思?
private static int inputCommand(){
int command;
try {
command = console.nextInt();
return command;
} catch (Exception e) {
//若輸入字符型或者字符串,則拋出異常,捕獲該異常,拋出”錯誤命令異?!?/p>
console = new Scanner(System.in);
//返回-1
return -1;
請問加下劃線的語句是什么意思?
2016-08-04
舉報(bào)
2016-08-05
這樣的一段局部代碼看不出來
2016-08-04
System.in是標(biāo)準(zhǔn)輸入設(shè)備。 Scanner是JAVA流里面的一個輸入類。
scanner console = new Scanner(System.in)就是從標(biāo)準(zhǔn)輸入設(shè)備(一般是鍵盤)中讀取數(shù)據(jù)。