1.

List<String>[] ls;
Object[] objects = ls;
objects[1] = new ArrayList<Integer>();

先把数组转化为Object[] ,通过Object[]下标进行赋值.

2.

List<BerylliumSphere>[] spheres = (List<BerylliumSphere>[]) new List[10];
        for(int i =0;i<spheres.length;i++) {
            spheres[i] = new ArrayList<BerylliumSphere>();            
        }

创建不带具体类型的List比如new List[10],然后强行转化为具体类型的List数组,编译不会报错,可以进行赋值.

相关文章:

  • 2021-09-28
  • 2021-11-22
  • 2022-01-14
  • 2022-12-23
  • 2022-01-12
  • 2022-01-30
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案