我有事件(接口)的列表,并通过一个类型列表,而不是接口,这是我想在我的方法如何用Java
public List<Event> getEvents(){ return list;}
回到我需要初始化列表中的类里面是什么。
List<EventImpl> list = new ArrayList<EventImpl>();
出于某种原因,我想我能做到这一点:
List<Event> list = new ArrayList<EventImpl>();
但现在看来,我做不到,所以我需要在getEvents一些铸造神奇的()?如果是的话,那是如何做到的?
谢谢
[是列表名单的子类?为什么不是Java的泛型隐式多态?](http://stackoverflow.com/questions/2745265/is-listdog-a-subclass-of-listanimal-why-arent-javas-generics-implicitly-p) –
August
2014-12-19 02:02:17
请参阅http ://docs.oracle.com/javase/tutorial/java/generics/erasure.html – smac89 2014-12-19 02:56:58