怎么会是ArrayList<Class<?>>
一样的擦除ArrayList<Object>
却不能投到它的情况呢?
我的代码目前正在两个 Eclipse 错误之间切换。
GenericExclusiveSelectionPanel transport =
new GenericExclusiveSelectionPanel(StringConstants.TRANSPORT,
(ArrayList<Object>)TransportManager.getInstance().getTransportTypes());
这表明:
Cannot cast from ArrayList<Class<Transportable>> to ArrayList<Object>
但是,如果我删除演员表并创建一个构造函数:
GenericExclusiveSelectionPanel(String, ArrayList<Class<Transportable>>)
我得到 eclipse 错误:
Erasure of method GenericExclusiveSelectionPanel(String,
ArrayList<Class<Transportable>>) is the same as another method in type
GenericExclusiveSelectionPanel
然后它将构造函数(如下)突出显示为冲突的构造函数。
GenericExclusiveSelectionPanel(String title, ArrayList<Object> arrayList)