小编Sau*_*abh的帖子

在Java中初始化2d列表

我是Java的新手,并尝试创建一个大小不固定的二维列表.我有一个类如下所示:

public class q1 {
    List<List<Integer> > L = new ArrayList<List<Integer> >(); 

    public void set(int m,int n){
        //This is the function which would get the size of the 2d list
    }
}
Run Code Online (Sandbox Code Playgroud)

我看到了答案,但它们必须是固定大小的,例如:

ArrayList<String>[][] list = new ArrayList[10][10];
Run Code Online (Sandbox Code Playgroud)

但是,我希望不同对象的列表L的大小不同.还有其他选项,比如copyOf,但上述功能是否可以通过这个数组实现?

java list arraylist

1
推荐指数
1
解决办法
1072
查看次数

标签 统计

arraylist ×1

java ×1

list ×1