Skip to main content

moregeek program

try-with-resources 语法简介-多极客编程

try-with-resources 语法特点 ①资源说明头()中可以包含多个定义,用分号隔开(最后的分号可以省略)。资源说明头()中定义的每个对象都会在try块的末尾调用其close()。 ②try-with-resources的try块可以独立存在,没有catch或finally都行。 ③实现了AutoCloseable的类都可以使用try-with-resources。 ④资源说明头()中对

Read More