#Does anyone know if the finally runs even if return is in try block?

1 messages · Page 1 of 1 (latest)

stuck solar
hollow sageBOT
#

<@&987246399047479336> please have a look, thanks.

hollow sageBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

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.

zinc gyro
#

yes

full shore
#

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

stuck solar
#

just to clarify when stack.pop() is returned, the code in finally runs? How is that possible if the method returns?

cursive sapphire
#

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

paper copper
#

nope

candid shuttle
#

May I ask the question What does lock.lock mean Call yourself I'm a newbie and don't understand very well

paper copper
#

System.exit will shutdown the vm

candid shuttle
#

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

cursive sapphire
full shore
cursive sapphire
#

but don't forget about shutdown hooks 😉

zinc gyro
hollow sageBOT
#

Closed the thread.

candid shuttle