L
laredotornado
Hi,
I'm using Java 6. If I have a class A, and a subclass B that extends
A, how can I cast a List<B> from a return type, List<A>? That is, I
have
List<B> myList = (List<B>)
DataInterface.getRandomizedResults(DataInterface.NEW_SEARCH, params);
The "DataInterface.getRandomizedResults" returns List<A>, however I am
guaranteed that all the elements in the List are of class B. As you
know the above results in a compile error and I'm trying to figure out
an elegant way to convert the data.
Thanks, - Dave
I'm using Java 6. If I have a class A, and a subclass B that extends
A, how can I cast a List<B> from a return type, List<A>? That is, I
have
List<B> myList = (List<B>)
DataInterface.getRandomizedResults(DataInterface.NEW_SEARCH, params);
The "DataInterface.getRandomizedResults" returns List<A>, however I am
guaranteed that all the elements in the List are of class B. As you
know the above results in a compile error and I'm trying to figure out
an elegant way to convert the data.
Thanks, - Dave