Hi Ranchere
I am new to javaranch . I have a confusion related to checked Exception . As in code showm below if we have empty try block and catches ’IOException’ ( as at line 1 ) it will give a compile time error saying
::“exception java.io.IOException is never thrown in body of corresponding try statement”
Where as if we catch ‘Exception’ with an empty try block code compiles fine.
I just want to know both ‘IOException’ & ‘Exception’ are checked exceptions than why code with line 2 compiles fine whereas code with line 1 fails to compiles ………
code ::
import java.io.*;
class ZZ{
public static void main(
String args[]){
try{ }catch(IOException e){e.printStackTrace();}//line 1
//try{ }catch(Exception e){e.printStackTrace();}//line 2
}
}
Thanks in advance