当前位置:网站首页>Execution sequence of finally and return
Execution sequence of finally and return
2022-07-24 05:10:00 【Bubble ^ bubble】
try() ⾥⾯ Yes ⼀ individual return sentence , Then ⾯ Of finally{}⾥⾯ Of code Will you be held ⾏, When to hold ⾏, Is in return Before or after return after ?
If try There is return sentence , that finally The code in will still execute ⾏. because return surface ⽰ It's all about ⽅ The body of the method returns , therefore ,finally The statements in the return Before that ⾏.
however return Previously executed finally block , The modification effect of data will be different for reference type and value type :
// test Modify the value type
static int test1() {
int ret = 0;
try {
return ret; // return 0,finally The modification effect in does not work
} finally {
ret++;
System.out.println("finally perform ");
}
}
// test Modify reference type
static int[] test2(){
int[] ret = new int[]{
0};
try {
return ret; // return [1],finally The modification effect in the works
} finally {
ret[0]++;
System.out.println("finally perform ");
}
}
边栏推荐
- To 3mm; Provide safe and stable product execution according to the sender IID
- 作、Ho量有关。嵌入,只有一70的该接
- Memorandum 2022
- Drools development decision table
- Some thoughts about blogger coach soserious
- Image to image translation with conditional advantageous networks paper notes
- yum 查看某个命令由哪个安装包提供
- [machine learning] - [traditional classification problem] - naive Bayesian classification + logistic regression classification
- pso和mfpso
- PSO and mfpso
猜你喜欢

Redis enhancements

greatest common divisor

Sort - quicksort

pso和mfpso

Post SQL era: edgedb 2.0 Release Notice

Use of fiddler packet capturing tool

C primer plus learning notes - 6. Arrays and pointers

Do you want to have a robot that can make cartoon avatars in three steps?

In his early 30s, he became a doctoral director of Fudan University. Chen Siming: I want to write both codes and poems

HCIA NAT experiment
随机推荐
What if the computer desktop gets stuck? Introduction of solutions to computer crash and desktop jamming
Hcde city closed door meeting successfully held in Nanjing station
Jiang Xingqun, senior vice president of BOE: aiot technology enables enterprise IOT transformation
Yum to see which installation package provides a command
C primer plus learning notes - 5. Pointer
)的低字节来反馈给应用层或者成多种格式文档:
Drools development decision table
MySQL transaction and its problems and isolation level
[Huang ah code] Introduction to MySQL - 3. I use select *, and the boss directly rushed me home by train, but I still bought a station ticket
un7.23:如何在linix上安装MySQL?
There is not enough space on the disk to complete this operation when partitioning the computer
What programmer is still being grabbed by the company at the age of 35? Breaking the "middle-aged crisis" of programmers
排序——QuickSort
Teach you how to weld CAD design board bottom (for beginners) graphic tutorial
greatest common divisor
pso和mfpso
微信朋友圈的高性能架构设计
Learning pyramid context encoder network for high quality image painting paper notes
Chapter 1 regression, classification & clustering
Binary SCA fingerprint extraction black Technology: go language Reverse Technology