💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
### 擦拭法 Java的泛型(Generic)是采用擦拭法(Type Erasure)实现的。 ![](http://blog.liufei1988.com/a826e9732c1b0156938e793b4598d63d) 擦拭法的局限: * <T>不能是基本类型,例如int * Object字段无法持有基本类型 * 无法取得带泛型的Class * 无法判断带泛型的Class * 不能实例化 T 类型 ![](http://blog.liufei1988.com/0690c97578c47efcbec4cd46cb17f7cf) 可以继承自泛型类: ``` public class IntPair extends Pair<Integer> { } ``` 子类可以获取父类的泛型类型。 继承关系: ``` Type | +- Class | +- ParameterizedType | +- GenericArrayType | +- WildcardType ```