Given this method:
public static <E extends Number> List<E> process(List<E> num)
I want to do this :
ArrayList<Integer> input = null ;
ArrayList<Integer> output = null ;
output = process(input);
I get an exception : Type mismatch: cannot convert from List<Integer> to ArrayList<Integer>
I know that I can have something correct like that :
List<Integer> list = new ArrayList<Integer>;
Why doesn’t it work here ?
The problem is the return type.
process()returns aList<E>and you’re trying to stuff that into anArrayList<E>