I have the following problem when using java generic. Basically I need to do a conversion from an list of subtype to a list of its supertype, and I defines a method like this:
public static <T> List<T> getList(List<? extends T> input) {
ArrayList<T> list = new ArrayList<T>();
list.addAll(input);
return list;
}
However I'm not sure how I can invoke this method? Given type A, B extends A:
List<A> alist = getList(List<B> blist);
has a mismatch type, because in this case I only supply B's type information to the method invocation.
How can I invoke the method with the type information A supplied?
Thanks.