Author | Message |
---|---|
Jordanton
Posts: 12
|
Posted 17:02 Mar 17, 2014 |
Dear professor, According to the Java API, the finally block will not be bypassed by a return. I just want to confirm this with you so that I won't run into the too many open connections problem on CS3. Thank you. |
redge
Posts: 31
|
Posted 17:06 Mar 17, 2014 |
From the Java documentation found here, "it allows the programmer to avoid having cleanup code accidentally bypassed by a return, continue, or break. Putting cleanup code in a finally block is always a good practice, even when no exceptions are anticipated."
If you're not convinced after reading that, testing it yourself is incredibly simple. Write a basic program whose main method returns, then prints something to the console in a finally block. If anything gets printed, you'll know the block was executed. |
cysun
Posts: 2935
|
Posted 20:14 Mar 17, 2014 |
Yeah, basically what REDGE said. |