Skip to content

Glossary: Software Design Patterns in Java

Try-with-resources

Also written: try with resources

A Java `try (...)` form that automatically calls `close()` on `AutoCloseable` objects when the block ends. It always opens and closes, while your block varies.

Where the book teaches it

Related terms

AutoCloseableTemplate method