不允许使用参数化类型的数组。

//无法创建 Box<Integer> 的通用数组
Box<Integer>[] arrayOfLists = new Box<Integer>[2]; 

由于编译器使用类型擦除,因此将type参数替换为对象,并且用户可以将任何类型的对象添加到数组中。并且在运行时,代码将无法引发ArrayStoreException。

//编译器错误,但如果允许
Object[] stringBoxes = new Box<String>[];
  
//OK
stringBoxes[0] = new Box<String>();  

//An ArrayStoreException should be thrown,
//but the runtime can't detect it.
stringBoxes[1] = new Box<Integer>();  

参考链接

https://www.learnfk.com/java-generics/java-generics-no-array.html