In Java, does return trump finally?

Posted by jonny five on Stack Overflow See other posts from Stack Overflow or by jonny five
Published on 2008-09-15T17:43:54Z Indexed on 2010/05/25 6:41 UTC
Read the original article Hit count: 252

Filed under:
|
|

If 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.

Thanks!

© Stack Overflow or respective owner

Related posts about java

Related posts about return