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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

寫了個(gè)差不多的異常,為什么會(huì)報(bào)錯(cuò)?求大神解答

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),編譯器錯(cuò)誤的提示信息是;No exception of type Exception can be thrown; an exception type must be a subclass of Throwable。



正在回答

2 回答

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

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

海上釣鰲客 提問者

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

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

異常類必須繼承

public class Exception?extends Throwable {

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

舉報(bào)

0/150
提交
取消

寫了個(gè)差不多的異常,為什么會(huì)報(bào)錯(cuò)?求大神解答

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

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

幫助反饋 APP下載

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

公眾號(hào)

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