the code:
public String get() { try { //doSomething return "Hello"; } finally { System.out.print("Finally"); }
code> How is this code executed?
Because the whole point of the block finallyis it executes, however you leave the block try, unless the virtual machine itself is disconnected.
finally
try
finally - , try, ? return, , . finally , , .
. JLS 14.20.2 - , finally.
, , , try (fail, return, exception, finish ..).
, , try/catch/finally.
This is what it means finally: the code inside will be executed when the block remains try, no matter how (with the exception of disabling the JVM through System.exit()or external reasons).
System.exit()
Source: https://habr.com/ru/post/1791212/More articles:Обеспечивает ли безопасность: зашифрованный зашифрованный результат зависит от сервера? - securityDeploying webservice from Team Foundation Server to IIS - tfsСбой приложения iOS при обновлении - iosHow to use API documentation in Eclipse? - eclipsePropertygrid properties not selected when using menu shortcut to save - winformsoracle: select * from tab for other types? - oracleРаспределение памяти заголовка TableView - memory-managementSelenium Grid: Hub Queue Size? - internet-explorerDoes Apple allow me to request promotional codes for apps rated 17+? - itunesconnectHow should I be mocking this simple service level method? - .netAll Articles