当前位置:网站首页>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;
}
}

边栏推荐
- Alibaba cloud sub account - Permission Policy - full control permission granted to an account and an OSS bucket
- No such file or directory: ‘/tmp/tmpxxx/tmpxxx.py‘
- Platform management background and business menu resource management: business permissions and menu resource management design
- 应广单片机开发 工规 PMC131 带AD芯片检测电池电压单片机SOP8/14
- [非线性控制理论]8_三种鲁棒控制器的比较
- Atcoder beginer contest 237 VP supplement
- When the industrial Internet began to enter the deep-water area, it appeared more in the form of industry
- 详解Kubernetes网络模型
- Virtual lab basic experiment tutorial -7 Polarization (1)
- Viewing technological changes through Huawei Corps (VI): smart highway
猜你喜欢

体验一下阿里云文字识别OCR

Virtual lab basic experiment tutorial -7 Polarization (1)
![[target tracking] |siamfc](/img/40/3419761d2eb7f1193b699cdd431761.png)
[target tracking] |siamfc

Linux中,mysql设置job任务自动启动

科班出身,面试小公司都进不去

外包干了五年,废了...
![[how is the network connected] Chapter 4 explores access networks and network operators](/img/50/d16f4dca571a5a5f9b20fada289d45.png)
[how is the network connected] Chapter 4 explores access networks and network operators

finally详解

【目标跟踪】|数据集汇总

Edgenext hit a mixed punch: a lightweight architecture integrating CNN and transformer
随机推荐
Daily question - inverted string
Asemi rectifier bridge umb10f parameters, umb10f specifications, umb10f package
515. 在每个树行中找最大值
easyAI笔记——深度学习
php获取两个时间戳之间相隔多少天多少小时多少分多少秒
2 juillet: BitTorrent est sorti; L'acquisition du système commercial linspire; Sony Deployment PlayStation now
[target tracking] |siamfc
好评率计算
[comment le réseau se connecte] chapitre 6: demande d'accès au serveur et réponse au client (terminé)
辉芒微IO单片机FT60F010A-URT
Wechat applet - arrows floating up and down
SAP commerce Cloud Architecture Overview
HDU - 1114 Piggy-Bank(完全背包)
台风来袭,多景区暂时关闭,省文旅厅提醒注意安全!
深入理解ThreadLocal
Problems needing attention in the development and debugging of Yingguang single chip microcomputer
嵌入式开发板 ~ 说明
No such file or directory: ‘/tmp/tmpxxx/tmpxxx.py‘
MB10M-ASEMI整流桥MB10M
Alibaba cloud sub account - Permission Policy - full control permission granted to an account and an OSS bucket