当前位置:网站首页>Finally detailed explanation
Finally detailed explanation
2022-07-02 17:53:00 【Change with affection】
public class test {
public static void main(String[] args) {
System.out.println(tryTest(8));
}
public static int tryTest(int i) {
int result = 0;
Integer obj = i;
try {
System.out.println(" perform try block ");
return result;
//return obj;
} catch (Exception e) {
//return -1;
e.printStackTrace();
} finally {
// No matter whether there is any abnormality or not ||try and catch There is return,finally All the code in the block will execute
System.out.println("final Yes ");
//finally Is in return After statement execution , Return to the previous execution ( The calculated value is not returned , Instead, save the value you want to return , No matter finally
// What about the code in , The value returned will not change , It's still a previously saved value ), So the return value of the function is at finally It has been determined before implementation .
System.out.println(" Reference type variable obj: " + obj + "; Basic data type variable result: " + result);
result = i;//finally The basic data type variable in does not change the returned content
obj = null;//finally The reference to type variables in does not change the returned content
System.out.println(" Reference type variable obj: " + obj + "; Basic data type variable result: " + result);
//finally If it contains return, Then the program will return here , instead of try or catch Medium return return , The return value is not try or catch The return value saved in .
return 999;
}
}

边栏推荐
- 科班出身,面试小公司都进不去
- 【網絡是怎樣連接的】第六章 請求到達服務器以及響應給客戶端(完結)
- [how is the network connected] Chapter 6 requests arrive at the server and respond to the client (end)
- PMS150C应广单片机开发案例
- 好评率计算
- 【网络是怎样连接的】第五章 探索服务器
- 原装应广单片机 MCU芯片PMS152 SOP8封装 单片机开发
- Wechat applet - arrows floating up and down
- aloam 代码阅读与总结
- 【Golang | gRPC】使用gRPC实现简单远程调用
猜你喜欢

Linux中,mysql设置job任务自动启动
![[非线性控制理论]8_三种鲁棒控制器的比较](/img/a8/03ed363659a0a067c2f1934457c106.png)
[非线性控制理论]8_三种鲁棒控制器的比较

Develop a controller that prohibits deleting namespaces

USB interface powered Bluetooth color light strip controller

HBuilderX运行到手机或模拟器提示没有找到设备

Easyswoole3.2 restart failed

My creation anniversary

MB10M-ASEMI整流桥MB10M

Mb10m-asemi rectifier bridge mb10m

每日一题——“水仙花数”
随机推荐
台风来袭,多景区暂时关闭,省文旅厅提醒注意安全!
Solution to the problem that the easycvr kernel of intelligent video analysis platform cannot be started as a service
Turn off the xshell connection server and the running jar package will stop automatically
【網絡是怎樣連接的】第六章 請求到達服務器以及響應給客戶端(完結)
Pms132b single chip microcomputer TWS digital tube Bluetooth charging chamber program development
【Golang | gRPC】使用openssl生成证书
Wasserstein Slim GAIN with Clipping Penalty(WSGAIN-CP)介绍及代码实现——基于生成对抗网络的缺失数据填补
Development and application case of pms134 scheme of Yingguang single chip microcomputer with original packaging
Atcoder beginer contest 237 VP supplement
Many scenic spots are temporarily closed due to the typhoon. The provincial culture and tourism department reminds you to pay attention to safety!
My creation anniversary
应广单片机开发 工规 PMC131 带AD芯片检测电池电压单片机SOP8/14
Modbus协议通信异常
Rk1126 platform project summary
VirtualLab基础实验教程-7.偏振(1)
PFC232-SOP8/14/16应广一级可带烧录程序编带
POJ - 1458 common subsequence (longest common subsequence)
【目标跟踪】|SiamFC
Keras' deep learning practice -- gender classification based on vgg19 model
Yingguang single chip microcomputer development specification pmc131 with AD chip to detect battery voltage single chip microcomputer sop8/14