See this piece of code:
import java.util.*;
public class Temp{
public static void main(String[] args){
List<int[]> list1 = new ArrayList<int[]>(); //WORKS!
List<double[]> list2 = new ArrayList<double[]>(); //WORKS!
//List<double> list3 = new ArrayList<double>(); //DOES NOT WORK
//List<int> list4 = new ArrayList<int>(); //DOES NOT WORK
}
}
AFAIK, java generics does not support primitive types, then how is int[] is compiling? How is autoboxing possible here?
int[]anddouble[]are object types which extendObjectThey are not primitives.You cannot auto box with arrays. Only between primitives and their wrappers.