I have a method with a parameter containing generics.
public static void readList(List<ModelObject> list)
{
// more code
}
I want to pass an ArrayList
of ModelObjectImplementation
s to this method.
ArrayList<ModelObjectImplementation> myList;
myList = ...
readList(myList); // gives compilation error
ModelObject
is an interface that ModelObjectImplementation
implements. How can I change the method declaration to allow this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…