亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

為什么這樣設置序號的時候,數組下標越界異常 不會報出“圖書不存在”

private static String getBookByNumber(String[] books)throws Exception{

System.out.println();

System.out.println("輸入書的序號:");

?int num =input.nextInt();

?

? ? ?for(int i = 0; i < books.length; i++) {

? ? if (books[num-1].equals(books[i])){

? ? return books[i];

? ? }

? ? }throw new Exception("圖書不存在!");

? ? ?}

?


正在回答

1 回答

肯定不會顯示啊,你這段代碼完全有問題的,加上try-catch

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

為什么這樣設置序號的時候,數組下標越界異常 不會報出“圖書不存在”

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號