Skip to content

Tag: try-with-resources

Why write Try-With-Resources without Catch or Finally?

Why write Try without a Catch or Finally as in the following example? Answer As explained above this is a feature in Java 7 and beyond. try with resources allows to skip writing the finally and closes all the resources being used in try-block itself. As stated in Docs Any object that implements java.lang.Auto…