我试图在调用方方法中捕获 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.");
}
}
}