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

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

這個代碼完全一摸一樣,為什么代碼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類的新建實例化對象

? ? ? ? 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)用寫錯了,main方法的第二個調(diào)用應該是test2()。

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

qq_慕婉清0460615 提問者

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

舉報

0/150
提交
取消

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

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

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

幫助反饋 APP下載

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

公眾號

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