I am trying to compile this code, but it keeps having an error,
errThrower.java:37: error: unreported exception Exception; must be caught or declared to be thrown
throw new Exception();
This exception is thrown in the callmethodErr()
, and I thought it has been caught in main, but I can't figure out what is happening.
Thanks all.
import java.util.IllegalFormatConversionException;
public class errThrower
{
public static void main(String[] args)
{
try
{
callmethodErr();
}
catch (Exception e)
{
e.printStackTrace();
}
}
public static void methodErr() throws Exception
{
System.out.println("error thrown from methodErr");
}
public static void callmethodErr()
{
try
{
methodErr();
}
catch (Exception e)
{
System.out.println("error thrown from callMethodErr");
throw new Exception();
}
}
}