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("白銀時(shí)代",4),new Book("伊豆舞女",5)};?? ??? ?System.out.println("現(xiàn)在的書有 :");?? ??? ?for (Book book2 : book) {?? ??? ??? ?System.out.println(book2.toString());?? ??? ?}?? ??? ?while(true){?? ??? ??? ?System.out.println("書名查找請(qǐng)按1;序號(hào)查找請(qǐng)按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("您輸入的類型不匹配,請(qǐng)重新輸入1或者2");?? ??? ??? ??? ?continue ;?? ??? ??? ?}catch (worryException c){?? ??? ??? ??? ?System.out.println("您輸入的書名有誤,請(qǐng)正確輸入書名");?? ??? ??? ??? ?continue ;?? ??? ??? ?}catch (ddddException d){?? ??? ??? ??? ?System.out.println("您輸入的序號(hào)有誤 請(qǐng)正確輸入序號(hào)");?? ??? ??? ??? ?continue ;?? ??? ??? ?}catch (Exception e){?? ??? ??? ??? ?System.out.println("其他類型錯(cuò)誤");?? ??? ??? ??? ?continue ;?? ??? ??? ??? ??? ??? ??? ?}?? ??? ??? ??? ??? ?}?? ?}}我想問的是 如果我想捕捉到上面幾個(gè)異常而不報(bào)錯(cuò) 我應(yīng)該怎么做上面如ddddExeption都是我自己定義的? 應(yīng)該如何改正才能沒有編譯錯(cuò)誤?
JAVA中try{}catch{}多種異常時(shí)的問題
qq_什么亡魂溺海沒有跳海實(shí)在_03283094
2017-03-01 23:35:26