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

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

try中有一個(gè)異常語(yǔ)句,后面只跟了一個(gè)finally, 返回上一級(jí)的時(shí)候?yàn)槭裁床蹲讲坏疆惓#?/h1>

package com.imooc;


import javax.xml.transform.TransformerException;






public class TestException { ?

? ? public TestException() { ?

? ? } ?

??

? ? boolean testEx() throws Exception { ?

? ? ? ? boolean ret = true; ?

? ? ? ? try { ?

? ? ? ? ? ? ret = testEx1(); ?

? ? ? ? } catch (Exception e) { ?

? ? ? ? ? ? System.out.println("testEx, catch exception"); ?

? ? ? ? ? ? ret = false; ?

? ? ? ? ? ? throw e; ?

? ? ? ? } finally { ?

? ? ? ? ? ? System.out.println("testEx, finally; return value=" + ret); ?

? ? ? ? ? ? return ret; ?

? ? ? ? } ?

? ? } ?

??

? ? boolean testEx1() throws Exception { ?

? ? ? ? boolean ret = true; ?

? ? ? ? try { ?

? ? ? ? ? ? ret = testEx2(); ?

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

? ? ? ? ? ? //System.out.println("echang=="+e);

? ? ? ? ? ? if (!ret) { ?

? ? ? ? ? ? ? ? return false; ?

? ? ? ? ? ? } ?

? ? ? ? ? ? System.out.println("testEx1, at the end of try"); ?

? ? ? ? ? ? return ret; ?

? ? ? ? } catch (Exception e) { ?

? ? ? ? ? ? System.out.println("testEx1游戲場(chǎng), catch exception"); ?

? ? ? ? ? ? ret = false; ?

? ? ? ? ? ? throw e; ?

? ? ? ? } finally { ?

? ? ? ? //System.out.println("異常是");

? ? ? ? ? ? System.out.println("testEx1, finally; return value=" + ret); ?

? ? ? ? ? ? return ret; ?

? ? ? ? } ?

? ? } ?

??

? ? boolean testEx2() throws Exception{ ?

? ? ? ? boolean ret = true; ?

? ? ? ? try { ?

? ? ? ? ? ? int b = 12; ?

? ? ? ? ? ? int c; ?

? ? ? ? ? ? for (int i = 2; i >= -2; i--) { ?

? ? ? ? ? ? ? ? c = b / i; ?

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

? ? ? ? ? ? } ?

? ? ? ? ? ? return true; ?

? ? ? ? } /*catch (NullPointerException e) { ?

? ? ? ? ? ? System.out.println("testEx2低級(jí)異常, catch exception"); ?

? ? ? ? ? ? ret = false; ?

? ? ? ? ? ? //System.out.println("e=="+e);

? ? ? ? ? ? throw e; ?

? ? ? ? ? ? //System.out.println("能不能執(zhí)行?");

? ? ? ? } */finally { ?

? ? ? ? ? ? System.out.println("testEx2低級(jí)最終要執(zhí)行, finally; return value=" + ret); ?


? ? ? ? ? ? return ret; ?

? ? ? ? } ?

? ? } ?

??

? ? public static void main(String[] args) { ?

? ?

? ? ? ? TestException testException1 = new TestException(); ?

? ? ? ? try { ?

? ? ? ? ? ? testException1.testEx(); ?

? ? ? ? } catch (Exception e) { ?

? ? ? ? ? ? e.printStackTrace(); ?

? ? ? ? } ?

? ? }?

}


正在回答

2 回答

testEx2()會(huì)出異常,但是你把catch注釋了,它當(dāng)然捕獲不到,而且因?yàn)檫@是非檢查異常,所以系統(tǒng)不會(huì)自動(dòng)拋出,所以定義testEx2() 時(shí)后面的throws Exception等于沒(méi)起到作用,也即上一級(jí)的testEx1()和testEx()都不會(huì)捕獲到異常

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

ziom

題主如果要采納我,請(qǐng)明天,今天我的采納滿(mǎn)了
2017-02-08 回復(fù) 有任何疑惑可以回復(fù)我~
#2

Deligence 提問(wèn)者

非常感謝!
2017-02-13 回復(fù) 有任何疑惑可以回復(fù)我~

main函數(shù)里好像沒(méi)有執(zhí)行testEx2()...

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

舉報(bào)

0/150
提交
取消

try中有一個(gè)異常語(yǔ)句,后面只跟了一個(gè)finally, 返回上一級(jí)的時(shí)候?yàn)槭裁床蹲讲坏疆惓#?/h1> 我要回答 關(guān)注問(wèn)題

微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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