'finally' block used without 'try' statement
The compiler detected a finally block but did not find a corresponding try statement. A finally block is used to execute code after a try statement, regardless of the results of the try statement.
The following example illustrates this error:
public class Simple {
public void method1() {
finally {
// error: missing corresponding try statement
}
}
}
The following example illustrates the correct usage of the finally block:
public class Simple{
public int method1(int arg1){
try{
arg1/10;
}
catch(Exception e){
//handle exception here; must come before 'finally'
}
finally{
//do something here; this section is run regardless of 'try'
}
}
}