Users Pricing

forum

Home Forums Does finally always execute in Java? – MindStick

Does finally always execute in Java?

Anonymous User 2032 08 May 2015
I have a try/catch block with returns inside it. Will the finally block be called?

For example:

try {  
    something();  
    return success;  
}  
catch (Exception e) {   
    return failure;  
}  
finally {  
    System.out.println("i don't know if this will get printed out.");
}
I know I can just type this in an see what happens (which is what I'm about to do, actually) but when I googled for answers nothing came up, so I figured I'd throw this up as a question.

1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md