take this code for example...
This one runs smoothly..
public class one
{
public static void main(String args[])
{
int i=27;
try
{
System.out.println(i/0);
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println(e);
}
catch(Exception e)
{
System.out.println(e);
}
}
}
However if i change the order it would give me a compile time error which in my sun sl-275 book is written it should run fine.
"If the Exception Catch clause is put first, then it would handle all exceptions, and the MyException or MyOtherException catch clauses would never be invoked."
which i think is wrong because the code never gets compiled...
public class one
{
public static void main(String args[])
{
int i=27;
try
{
System.out.println(i/0);
}
catch(Exception e)
{
System.out.println(e);
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println(e);
}
}
please discuss.