当前位置:网站首页>Understand the execution sequence of try catch finally in one diagram
Understand the execution sequence of try catch finally in one diagram
2022-06-25 15:59:00 【Favorite grapes】
What is? try-catch-finally
yes java Is used to catch exceptions , And handle exceptional blocks .
- try In the block are the codes that may cause exceptions
- catch The possible exceptions are placed in the block
- finally The block contains code that must be executed
Understand the execution sequence with a picture

Use scenarios ( Database operation as an example )
When accessing a database , An error may occur during execution , At this point through try-catch Block for processing
DataBase db;
try {
User user = db.getUser();
return user;
} catch (DBException e) {
e.printStack();
return null;
} finally {
db.close();
}
Detailed conclusion
- finally There is... In the block return sentence , Returns the finally Medium return Value
- No matter what catch Block or try Whether there is in the block return sentence ,finally The statement in must execute
- finally in return When the sentence is , The compiler will warn , But there is no error .
边栏推荐
- MySQL修改字段語句
- 转换Cifar10数据集
- The paid video at station B caused the up master to lose more than ten thousand fans
- JS的注释
- [issue 24] one year experience of golang to develop futu
- Read the configuration, explain the principle and read the interview questions. I can only help you here...
- Ten routing strategies for distributed task scheduling platform XXL job
- 面试官:你简历上说精通mysql,那你说下聚簇/联合/覆盖索引、回表、索引下推
- What is session? How is it different from cookies?
- 通俗讲跨域
猜你喜欢

说下你对方法区演变过程和内部结构的理解

The style of the mall can also change a lot. DIY can learn about it!

Sword finger offer 05 Replace spaces
Cloning and importing DOM nodes

Lifeifei's team applied vit to the robot, increased the maximum speed of planning reasoning by 512 times, and also cued hekaiming's MAE
Time wheel and implementation analysis of time wheel in go zero

Interviewer: your resume says you are proficient in mysql, so you say cluster / Union / overlay index, table return, index push down
Super comprehensive custom deep copy function

免费送书啦!火遍全网的AI给老照片上色,这里有一份详细教程!

TFIDF and BM25
随机推荐
Don't underestimate the integral mall, its role can be great!
Servlet详解
深度学习 pytorch cifar10数据集训练「建议收藏」
Pytest测试框架笔记
Take you to the open source project of smart home: the preliminary configuration of zhiting home cloud and home assistant+ homebridge
Brief object memory layout
中国高校首次!全球唯一!同济学子斩获国际大奖
VectorDraw Developer Framework 10.1001 Crack
剑指 Offer 10- I. 斐波那契数列
golang正则regexp包使用-05-扩展Expand()、根据正则切割Split()
Message format of Modbus (PLC)
Practice of geospatial data in Nepal graph
Describe your understanding of the evolution process and internal structure of the method area
不要小看了积分商城,它的作用可以很大!
Multithreading, parallelism, concurrency, thread safety
Create raspberry PI image file of raspberry pie
《睡眠公式》:怎么治睡不好?
Mark the same items in the Li list in red
基于深度Q学习的雅达利打砖块游戏博弈
Do you want to go to an outsourcing company? This article will give you a comprehensive understanding of outsourcing pits!