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

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

newExc

newExc是什么意思?從哪里來的?好像沒有定義過?。。?/p>

正在回答

3 回答

public class test_1 {

?? ?public static void main(String[] args) {
?? ??? ?test_1 result = new test_1();
?? ??? ?result.deal2();
?? ?}
?? ?public class DIYException1 extends Exception {
?? ??? ?public DIYException1() {
?? ??? ?}
?? ?}
?? ?public class DIYException2 extends Exception {
?? ??? ?public DIYException2() {
?? ??? ?}
?? ?}
?? ?//自定義兩種異常
?? ?public void test() throws DIYException1 {
?? ??? ?throw new DIYException1();
?? ?}
?? ?//通過test(),拋出異常1
?? ?public void deal1() throws DIYException2 {
?? ??? ?try {
?? ??? ??? ?test();
?? ??? ?} catch (DIYException1 e) {
?? ??? ??? ?System.out.println("error1");
?? ??? ??? ?throw new DIYException2();
?? ??? ?}?? ?
?? ?}
?? ?//檢測到異常1拋出后,拋出異常2,并輸出error1
?? ?public void deal2() {
?? ??? ?try {
?? ??? ??? ?deal1();
?? ??? ?} catch (DIYException2 e) {
?? ??? ??? ?System.out.println("error2");
?? ??? ?}
?? ?}
?? ?//檢測到異常2后,輸出error2
}

.initCause()是Exception中封裝好的一些方法

0 回復(fù) 有任何疑惑可以回復(fù)我~

newExc.initCause(e);是用來干什么的?

0 回復(fù) 有任何疑惑可以回復(fù)我~

新的RuntimeException就叫做newExc,文中有定義:RuntimeException newExc=new RuntimeException,新的newExc是用來接收上個文件傳進(jìn)來的異常的.


0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消
Java入門第三季
  • 參與學(xué)習(xí)       409775    人
  • 解答問題       4546    個

Java中你必須懂得常用技能,不容錯過的精彩,快來加入吧

進(jìn)入課程
微信客服

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

幫助反饋 APP下載

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

公眾號

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