【发布时间】:2021-05-26 09:23:45
【问题描述】:
我试图在调用方方法中捕获 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.");
}
}
}
【问题讨论】:
-
static void fun() throws IllegalAccessException -
它给了你什么错误?
标签: java exception illegalaccessexception