第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

JAVA中try{}catch{}多種異常時的問題

JAVA中try{}catch{}多種異常時的問題

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)該如何改正才能沒有編譯錯誤?
查看完整描述

1 回答

?
虛無縹緲丶

TA貢獻17條經(jīng)驗 獲得超14個贊

定義自定義異常類

public?class?aaaException?extends?RuntimeException?{

}


查看完整回答
反對 回復(fù) 2017-03-02
  • 1 回答
  • 0 關(guān)注
  • 1587 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號