February 2014
Beginner
1248 pages
62h 25m
English
• The try-with-resources statement (p. 467) simplifies writing code in which you obtain a resource, use it in a try block and release the resource in a corresponding finally block. Instead, you allocate the resource in the parentheses following the try keyword and use the resource in the try block; then the statement implicitly calls the resource’s close method at the end of the try block.
• Each resource must be an object of a class that implements the AutoCloseable interface (p. 467)—such a class has a close method.
• You can allocate multiple resources in the parentheses following try by separating them with a semicolon (;).
Read now
Unlock full access