Hi,
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");
}
}
This piece of code does not give any comile time error( runs well and gives output before try At the End) whereas the following code :
public class AQuestion
{
public static void main(String args[])
{
System.out.println("Before Try");
try
{
}
catch(java.io.IOException t)
{
System.out.println("Inside Catch");
}
System.out.println("At the End");
}
}
is giving a compile time error : exception java.io.IOException is never thrown in the body of corresponding try statement.
I am not able to understand why the first code is running properly and the second is giving a compile time error ?
Thanks .