运行程序包括try块但没有catch或final子句

Nip*_*oon 2 java exception-handling try-catch

通常这会给出语法错误.但是在Statement部分的oracle教程try-with-resources,有几个带有try块但没有catchfinally语句的代码示例.为什么这些代码不会出现语法错误?

Cod*_*der 5

try with resources块中,finally添加了一个隐含的代码,close()在所有Closable实例上调用该方法...

因此,a finally仍然存在于块中.所以它在语法上是正确的.