【发布时间】:2018-12-13 03:29:40
【问题描述】:
您好,我想重写自定义类 MyList 中的构造函数。
下面的代码可以编译,我收到“相同的擦除”错误。对于编译器List<CustomClass1> 与List<CustomClass2> 的类型相同
有人可以建议我如何解决这个问题。我尝试使用List<Object> 和instanceof,但我无法解决这个问题,但没有成功
private static class MyList {
private int type;
public MyList (List<CustomClass1> custom1) {
type = 1;
}
public MyList (List<CustomClass2> custom2) {
type = 2;
}
}
【问题讨论】: