JavaIntermediate#exceptions

Explain try-with-resources.

A try statement that declares resources implementing AutoCloseable; they are closed automatically at the end of the block, even on exception. Replaces verbose finally blocks.

Example
try (BufferedReader br = new BufferedReader(new FileReader("f.txt"))) {
  System.out.println(br.readLine());
} // br.close() called automatically

Related Questions

1
JavaIntermediate#fundamentals

What is autoboxing and unboxing?

Open
2
JavaIntermediate#collections

What is the difference between Comparable and Comparator?

Open
3
JavaAdvanced#jvm

What is reflection in Java?

Open