当前位置:网站首页>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;
}
}
边栏推荐
- 详解Kubernetes网络模型
- 【网络是怎样连接的】第五章 探索服务器
- [comment le réseau se connecte] chapitre 6: demande d'accès au serveur et réponse au client (terminé)
- Daily question - inverted string
- Yingguang single chip microcomputer (MCU popular science)
- Two pieces of nature a day! Duan Fengfeng, an alumnus of the University of science and technology of China, was the third Chinese winner of the belby medal
- Larvel document reading notes custom authentication login and registration using larvel 8
- finally详解
- 【网络是怎样连接的】第六章 请求到达服务器以及响应给客户端(完结)
- Use of nexttile function in MATLAB
猜你喜欢
Edgenext hit a mixed punch: a lightweight architecture integrating CNN and transformer
MySQL进阶-事务及索引
[非线性控制理论]7_High gain and High Frequency
透过华为军团看科技之变(六):智慧公路
Modbus protocol communication exception
每日一题——“水仙花数”
Easyai notes - machine learning
Viewing technological changes through Huawei Corps (VI): smart highway
HBuilderX运行到手机或模拟器提示没有找到设备
List summation [dummy+ tail interpolation + function processing list reference common pit]
随机推荐
What is the experience of maintaining Wanxing open source vector database
【目标跟踪】|数据集汇总
HDU - 1114 Piggy-Bank(完全背包)
Redisson high performance redis distributed lock source code analysis
wps插入图片后使图片完整显示
外包干了五年,废了...
Turn off the xshell connection server and the running jar package will stop automatically
[today in history] July 2: BitTorrent came out; The commercial system linspire was acquired; Sony deploys Playstation now
每日一题——倒置字符串
Many scenic spots are temporarily closed due to the typhoon. The provincial culture and tourism department reminds you to pay attention to safety!
Rk1126 platform project summary
应广单片机开发调试应注意的问题
应广单片机开发 工规 PMC131 带AD芯片检测电池电压单片机SOP8/14
JDBC
finally详解
详解Kubernetes网络模型
嵌入式开发板 ~ 说明
em120.gige.h
Modbus protocol communication exception
Daily question - xiaolele changes the number