Suppose I have MyEdge
and MyEdgeModified
, such that MyEdge
is the superclass and MyEdgeModified
is the subclass. Now, suppose I do this:
List<List<MyEdge>> collectionOfEdgeLists = new LinkedList<List<MyEdge>>();
for(int i = 0; i < someValue; i++) {
List<MyEdgeModified> newList = someMethod();
collectionOfEdgeLists.add(newList); //ruh roh
}
Now, if I do this:
private List<MyEdge> convert(final List<MyEdgeModified> list) {
final List<MyEdge> otherList = new ArrayList<MyEdge>(list.size());
for(Edge edge : list) {
otherList.add(edge);
}
return otherList;
}
Then:
collectionOfEdgeLists.add(convert(newList)); //ok...
Now, the problem I'm seeing here is that I can treat each individual MyEdgeModified
as an Edge
, but if I have a collection I have to first build a whole 'nother list to be able to use it. Why? Am I doing something wrong? This seems wrong and dumb to me.