If you catch a return statement there, what finally will execute the code inside it?

It will be executed before

public class test {
	public static int getInt(){
		int a=10;
		try{
			System.out.println(a/0);
			a=20;
		}catch(Exception e){
			a=30;
			return a;
		}finally{
			a=40;
		}
		return a;
	}	
	public static void main(String[] args) {
		
		System.out.println(getInt());
	}
}

result:

30

Here Insert Picture Description
Here Insert Picture Description

He published 188 original articles · won praise 10 · views 10000 +

Guess you like

Origin blog.csdn.net/Ting1king/article/details/104928800