I am trying to use the finally block without using the try/catch blocks but getting the error in Eclipse.
Can I use the finally block without using the try/catch blocks?
You must have a try
block with a finally
block. The try
block defines which lines of code will be followed by the finally
code. If an exception is thrown prior to the try
block, the finally
code will not execute.
Adding catch
blocks is optional:
try {
// something
} finally {
// guaranteed to run if execution enters the try block
}