我试图在我的文件中捕获 InvocationTargetException,但如果我没有明确地为它编写 import 语句,我就会收到这个错误。
既然在java.lang的一个子包下,不知道为什么要导入。
//this is the import statement that worked
import java.lang.reflect.InvocationTargetException;
Run Code Online (Sandbox Code Playgroud)
这是错误消息:
source\DatabaseDemo.java:38: error: cannot find symbol
}catch (NoSuchMethodException | InstantiationException | SQLException | ClassNotFoundException | IllegalAccessException | InvocationTargetException e ){
^
symbol: class InvocationTargetException
location: class DatabaseDemo
Run Code Online (Sandbox Code Playgroud)