📅  最后修改于: 2020-11-15 04:09:14             🧑  作者: Mango
由于编译器使用类型擦除,因此运行时不会跟踪类型参数,因此在运行时,无法使用instanceOf运算符验证Box
Box integerBox = new Box();
//Compiler Error:
//Cannot perform instanceof check against
//parameterized type Box.
//Use the form Box> instead since further
//generic type information will be erased at runtime
if(integerBox instanceof Box) { }