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

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

寫了個差不多的異常,為什么會報錯?求大神解答

package exception;

public class Exception {


public static void main(String[] args) {

// TODO Auto-generated method stub

? ? ? ? Exception tct =new Exception();?

int result = 0;

? ? ? ? ?result = tct.test1();

? ? ? ? ?System.out.println("result= "+result);

}

public int test1(){

int div = 10;

int result = 100;

try{while(div>-1)

{div--;

? ? ?result= result + 100/div;}

return result;

}catch(Exception e){

e.printStackTrace();

System.out.println("捕獲異常");

return -1;

}

}


}

問題出在了catch(Exception e),編譯器錯誤的提示信息是;No exception of type Exception can be thrown; an exception type must be a subclass of Throwable。



正在回答

2 回答

我也試了下,應(yīng)該是你在同一個包里面建了兩個類,你把這個程序放在另外一個包里面試一下

0 回復 有任何疑惑可以回復我~
#1

海上釣鰲客 提問者

非常感謝!
2015-07-27 回復 有任何疑惑可以回復我~

提示說的很明確了:No exception of type Exception can be thrown; an exception type must be a subclass of Throwable。

異常類必須繼承

public class Exception?extends Throwable {

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

寫了個差不多的異常,為什么會報錯?求大神解答

我要回答 關(guān)注問題
微信客服

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

幫助反饋 APP下載

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

公眾號

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