import java.util.*;public class CheckBook{? public static final String[] book = {"春天日記","高等數(shù)學","計算機概述","網(wǎng)絡設計","論語","青春的躁動","大學英語"};? Scanner scanner = new Scanner(System.in);? public static void main(String[] args){? ? CheckBook checkBook = new CheckBook(); ?? ? try{? ? ? checkBook.test1();? ? }catch(Exception e){? ? ? e.printStaceTrack();? ? }finally{? ? ? System.out.println("期待您的下次光臨!");? ? }? }? public void test1()throws Exce {? ? while(true){? ? ? System.out.println("請輸入您要查詢的id:");? ? ? if(scanner.hasNextInt()){? ? ? ? int number = scanner.nextInt();? ? ? ? if(number>book.length || number<0){? ? ? ? ? throw new Exce("序號不存在!");? ? ? ? }else{? ? ? ? ? System.out.println("請輸入書籍名稱:"); ? ? ? ??? ? ? ? ? String bookName = scanner.next();? ? ? ? ? if(bookName.equals(book[number-1])){? ? ? ? ? ? System.out.println("圖書館中有此書,書的序號為:"+number);? ? ? ? ? ? break;? ? ? ? ? }else{? ? ? ? ? ? throw new Exce("圖書不存在!");? ? ? ? ? }? ? ? ? }? ? ? }else{? ? ? ? throw new Exce ("錯誤命令異常!");? ? ? }? ? }? }
編譯提示 找不到符號,錯誤指向 main函數(shù)的 catch語句塊后來的 e?
weibo_快樂is魏帆_0
2016-07-08 09:42:26