标签:class 初始化 system bsp int span style add asList
package xiaoling; import java.util.Arrays; import java.util.ArrayList; import java.util.List; public class ListTest{ public static void main(String[] args){ List<List<Integer>> list = new ArrayList<>(); for (int num=0; num<10; ++num){ list.add(new ArrayList(Arrays.asList(num, num+1))); } System.out.println(list); } }
运行结果为:[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]
Java中使用Arrays.asList初始化ArrayList
标签:class 初始化 system bsp int span style add asList
原文地址:https://www.cnblogs.com/wangling1820/p/11666522.html