The code below doesn't compile due to a type compatibility error on line 8. I understand that. What I would like to know is the why??
Why is it that line 7 compiles just fine. In line 7 Arrays.asList() returns a List<Integer> and assigns it to a List<Number>. In line 8 new ArrayList<Integer> is being attempted to assigned to ArrayList<Number>. Why is that not allowed where as the assignment of List<Integer> to List<Number> is allowed.
The javadoc for Arrays.asList says: public static <T> List<T> asList(T....a).