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

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

請大神看一下,錯誤是:a1 cannot be resolved to a variable。求解釋一下哈

請大神看一下,錯誤是:a1 cannot be resolved to a variable。求解釋一下哈

Rogerl 2015-06-29 12:48:02
package?com.imooc;import?java.util.Scanner;?public?class?BorrowBook?{????String[]?shu={"高數","大學英語","計算機"};????Scanner?sc?=?new?Scanner(System.in);?public?void?test1(){????System.out.println("輸入命令1或2:1代表按照書名查找圖書;2代表按照序號查找圖書");}?public?void?test2()?throws?Exception{????test1();????int?a1=sc.nextInt();????if?(a1!=1||a1!=2){?????throw?new?Exception("命令輸入錯誤;請根據提示輸入數字命令!!");?????}???}public?void?test3()?{??try{??????test2();????}catch(Exception?e){????test3();}if(a1==1){????System.out.println("請輸入圖書名");????String?a2=sc.next();????for(int?i=0;i<3;i++){????????if(a2==shu[i])????????????System.out.println("book:"+a2);????}}????else?if(a1==2)????{????????System.out.println("請輸入圖書序號");????????int?b2=?sc.nextInt();????????for(int?i=0;i<3;i++){????????????if(b2==i)????????????????System.out.println("book:"+shu[i]);????}????System.out.println("圖書不存在");}}}
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 2638 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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