If I write code in try block that never throws an "Exception" and catch it as catch(Exception e){}
it works. Basically, This works:
import java.io.*;
class NeverThrownException {
public static void main (
String[] args) {
try{
return;
}
catch(Exception e){
System.out.println("caught exception");
}
finally{
System.out.println("Finally");
}
} // end of main ()
}
But I have something more specific like IOException instead of Exception it gives me a compile time error:
exception java.io.IOException is never thrown in body of corresponding try statement
catch(IOException e){
this doesnt work:
import java.io.*;
class NeverThrownException {
public static void main (String[] args) {
try{
return;
}
catch(IOException e){
System.out.println("caught IOexception");
}
finally{
System.out.println("Finally");
}
} // end of main ()
}
any ponters?
Thanks.