Exception
and IOException
both are compile time checked exceptions.
But, we cant use IOException
within catch block. But we can use Exception
within catch block what is the reason for it.
import java.io.*;
class Demo{
public static void main(String args[]){
try{
}catch(IOException e){ // Does not compile
}
try{
}catch(Exception e){ // Compile
}
}
}