Java implicit try-with-resources
问题 I am wondering if the following code uses the try-with-resources correctly. try (ResultSet rs = new QueryBuilder(connection, tableName(), getPaths(), searchQuery()).add(constraint).build().executeQuery()) { while (rs.next()) { beans.add(createBean(rs)); } } The arguments are not important, the only important thing is: new QueryBuilder().build(); returns a PreparedStatement . I completely understand that rs will be closed, but will the PreparedStatement also be closed, and if so, for what