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

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

這個(gè)代碼完全一摸一樣,為什么代碼finally后面的syso不執(zhí)行了


package com.imooc.test;


import javax.naming.spi.DirStateFactory.Result;


public class TryCatchTest {


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

? ? ? ? // TODO Auto-generated method stub

? ? ? ? TryCatchTest tct? = new TryCatchTest();

? ? ? ? int result = tct.test();

? ? ? ? System.out.println("test()方法執(zhí)行完畢!返回值為:"+result);

? ? ? ??

? ? ? ? int result2 = tct.test();//tct是TryCatchTest類的新建實(shí)例化對(duì)象

? ? ? ? System.out.println("我想大聲告訴你,test2()方法執(zhí)行完畢!返回值為:");

? ? ??

? ? }

? ? public int test(){

? ? ? ? int divider = 10;

? ? ? ? int result = 100;

? ? ? ? try {

? ? ? ? ?while (divider > -1) {

? ? ? ? ? ? ?divider--;

? ? ? ? ? ? ?result =result + 100/divider;

? ? ? ? } return result;?

? ? ? ? } catch (Exception e) {

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

? ? ? ? ? System.out.println("循環(huán)拋出異常了!");?

? ? ? ? ? return-1;

? ? ? ? }

? ? ? ??

? ? }

? ? public int test2(){

? ? ? ? int divider = 10;

? ? ? ? int result = 100;

? ? ? ? try {

? ? ? ? ?while (divider > -1) {

? ? ? ? ? ? ?divider--;

? ? ? ? ? ? ?result =result + 100/divider;

? ? ? ? } return result;?

? ? ? ? } catch (Exception e) {

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

? ? ? ? ? System.out.println("循環(huán)拋出異常了!");?

? ? ? ? ? return result=999;

? ? ? ? }finally {

? ? ? ? ? ?

? ? ? ? ? ? System.out.println("這是finally,哈哈");

? ? ? ? ? ? System.out.println("我是result,我的值是"+result);

? ? ? ? }

? ? }

}


正在回答

1 回答

你函數(shù)調(diào)用寫錯(cuò)了,main方法的第二個(gè)調(diào)用應(yīng)該是test2()。

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

qq_慕婉清0460615 提問者

謝謝,我先看看
2020-04-29 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

這個(gè)代碼完全一摸一樣,為什么代碼finally后面的syso不執(zhí)行了

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

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

幫助反饋 APP下載

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

公眾號(hào)

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