I have the following contrived code:
class Exception
{
public static void main(String args[])
{
int x = 10;
int y = 0;
int result;
try{
result = x / y;
}
catch(ArithmeticException e){
System.out.println("Throwing the exception");
throw new ArithmeticException();
}
catch(Exception ae){
System.out.println("Caught the rethrown exception");
}
}
}
The first catch block restores the exception that was detected. However, the compiler says "Incompatible types are required" and "Throwable". Why did this error occur?
source
share