我试图在调用者方法中捕获 IllegalAccessException。但它无法抓住它。相反,它给出了一个错误。
{
static void fun()
{
try{
System.out.println("Inside fun(). ");
throw new IllegalAccessException("demo");
}catch(IllegalAccessException e){
throw e;
}
}
public static void main(String args[])
{
try
{
fun();
}
catch(IllegalAccessException e)
{
System.out.println("caught in main.");
}
}
}