Skip to main content
  1. About
  2. For Teams
The error handling part will be very helpful based on the answer of this question
Link
spelling
Source Link
Matthias Braun
  • 34.9k
  • 27
  • 158
  • 177

Considering this code, can I be absolutely sure that the finally block always executes, no matter what something() is?

try {  
    something();  
    return success;  
}  
catch (Exception e) {   
    return failure;  
}  
finally {  
    System.out.println("i"I don't know if this will get printed out."out");
}

Considering this code, can I be absolutely sure that the finally block always executes, no matter what something() is?

try {  
    something();  
    return success;  
}  
catch (Exception e) {   
    return failure;  
}  
finally {  
    System.out.println("i don't know if this will get printed out.");
}

Considering this code, can I be absolutely sure that the finally block always executes, no matter what something() is?

try {  
    something();  
    return success;  
}  
catch (Exception e) {   
    return failure;  
}  
finally {  
    System.out.println("I don't know if this will get printed out");
}
Minor title improvment
Link
Steve Chambers
  • 39.8k
  • 29
  • 179
  • 222

Does a finally block always executeget executed in Java?

deleted 164 characters in body
Source Link
Loading
Question Protected by CommunityBot
removing duplicate tag finally, since finally is already included in try-catch-finally tag
Link
Loading
deleted 3 characters in body; edited title
Source Link
Ripon Al Wasim
  • 38k
  • 42
  • 159
  • 180
Loading
Reformatted code
Source Link
RB.
  • 37.4k
  • 13
  • 103
  • 137
Loading
deleted 11 characters in body; edited tags
Source Link
Jonas
  • 130.6k
  • 103
  • 330
  • 408
Loading
give the sample code a chance of compiling
Source Link
Joachim Sauer
  • 309.3k
  • 59
  • 568
  • 624
Loading
Post Merged (destination) from stackoverflow.com/questions/2824746/finally-and-return
Source Link
jonny five
  • 27.6k
  • 3
  • 23
  • 12
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.