#Does anyone know if the finally runs even if return is in try block?
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
While you are waiting for getting help, here are some tips to improve your experience:
If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.
Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.
yes
Yes
Finally is always run
Unless u call System#exit
If you have a return in the try block and return in the finally block, the one in the finally block is actually returned
just to clarify when stack.pop() is returned, the code in finally runs? How is that possible if the method returns?
Seems correct - https://stackoverflow.com/a/65185
finally will always run even if the method has returned
how is it possible? java is just built like that - finally will run before returning
nope
May I ask the question What does lock.lock mean Call yourself I'm a newbie and don't understand very well
System.exit will shutdown the vm
#1051826284008853505
Here's the problem: the landlord sends out lock.lock() in the picture. What is the meaning
I just learned and didn't understand very well
ah it does, I always remember being told it would run even before a shutdown, oh well - ignore my system.exit comment
Yes I said system.exit is the only thing tht can stop finslly
but don't forget about shutdown hooks 😉
calling the method lock() on the class field lock
Closed the thread.
Thank you for your reply