package RentBook;import java.util.Scanner;import org.omg.CORBA.ExceptionList;public class Initial {?? ?public static void main(String[] args) {?? ??? ?// TODO Auto-generated method stub?? ??? ?Book book[] = {new Book("算法導(dǎo)論",1),new Book("大學(xué)英語",2),new Book("java圣經(jīng)",3),new Book("白銀時代",4),new Book("伊豆舞女",5)};?? ??? ?System.out.println("現(xiàn)在的書有 :");?? ??? ?for (Book book2 : book) {?? ??? ??? ?System.out.println(book2.toString());?? ??? ?}?? ??? ?while(true){?? ??? ??? ?System.out.println("書名查找請按1;序號查找請按2");?? ??? ??? ?Scanner console = new Scanner(System.in);?? ??? ??? ?try{?? ??? ??? ??? ?int t = console.nextInt();?? ??? ??? ??? ?if(t == 1){?? ??? ??? ??? ??? ?console = new Scanner(System.in);?? ??? ??? ??? ??? ?String chooseName = console.next();?? ??? ??? ??? ??? ?for(int i = 0; i<book.length ;i++){?? ??? ??? ??? ??? ??? ?if(chooseName.equals(book[i].getName())){?? ??? ??? ??? ??? ??? ??? ?System.out.println("您選中的書為"+book[i].toString());?? ??? ??? ??? ??? ??? ?}?? ??? ??? ??? ??? ?}?? ??? ??? ??? ?}else if(t == 2){?? ??? ??? ??? ??? ?console = new Scanner(System.in);?? ??? ??? ??? ??? ?int chooseNum = console.nextInt();?? ??? ??? ??? ??? ?for(int i = 0; i<book.length ;i++){?? ??? ??? ??? ??? ??? ?if(chooseNum == book[i].getNum()){?? ??? ??? ??? ??? ??? ??? ?System.out.println("您選中的書為"+book[i].toString());?? ??? ??? ??? ??? ??? ?}?? ??? ??? ??? ??? ?}?? ??? ??? ??? ?}?? ??? ??? ?}catch (aaaException e){?? ??? ??? ??? ?System.out.println("您輸入的類型不匹配,請重新輸入1或者2");?? ??? ??? ??? ?continue ;?? ??? ??? ?}catch (worryException c){?? ??? ??? ??? ?System.out.println("您輸入的書名有誤,請正確輸入書名");?? ??? ??? ??? ?continue ;?? ??? ??? ?}catch (ddddException d){?? ??? ??? ??? ?System.out.println("您輸入的序號有誤 請正確輸入序號");?? ??? ??? ??? ?continue ;?? ??? ??? ?}catch (Exception e){?? ??? ??? ??? ?System.out.println("其他類型錯誤");?? ??? ??? ??? ?continue ;?? ??? ??? ??? ??? ??? ??? ?}?? ??? ??? ??? ??? ?}?? ?}}我想問的是 如果我想捕捉到上面幾個異常而不報錯 我應(yīng)該怎么做上面如ddddExeption都是我自己定義的? 應(yīng)該如何改正才能沒有編譯錯誤?
JAVA中try{}catch{}多種異常時的問題
qq_什么亡魂溺海沒有跳海實在_03283094
2017-03-01 23:35:26