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("算法导论",1),new Book("大学英语",2),new Book("java圣经",3),new Book("白银时代",4),new Book("伊豆舞女",5)}; System.out.println("现在的书有 :"); 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 ; } } }}我想问的是 如果我想捕捉到上面几个异常而不报错 我应该怎么做上面如ddddExeption都是我自己定义的 应该如何改正才能没有编译错误?
添加回答
举报
0/150
提交
取消