Hello everybody.....
I have a basic doubt on Exceptions..... hope somebody out there can clear it off....
I have two pieces of code.... The first one compiles fine...
public class AQuestion
{
public static void main(String args[])
{
System.out.println("Before Try");
try
{
}
catch(Throwable t)
{
System.out.println("Inside Catch");
}
System.out.println("At the End");
}
}
The second piece of code has an IOException in the catch clause:
import java.io.*;
public class AQuestion
{
public static void main(String args[])
{
System.out.println("Before Try");
try
{
}
catch(IOException t)
{
System.out.println("Inside Catch");
}
System.out.println("At the End");
}
}
This piece gives a compiler error saying:
C:\java\bin>javac Throw.java
Throw.java:11: Exception java.io.IOException is never thrown in the body of the corresponding try statement.
catch(IOException t)
^
1 error
What I do not understand is why does the compiler perform this check only for subclasses of the Throwable class and not for the Throwable class itself.....
Please help me here.....