{ List<Integer> list = Lists.newArrayList();//创建空集合 List<Integer> list_2 = Lists.newArrayList(1, 2, 3);//快速初始化集合 System.out.println(list_2); } { List<Integer> list1 = Lists.newArrayList(1, 2, 3); List<Integer> list2 = Lists.newArrayList(4, 5); List<List<Integer>> productList = Lists.cartesianProduct(list1, list2);//将两个集合做笛卡尔积 System.out.println(productList); } { List<Integer> list = Lists.newArrayList(1, 2, 3, 4, 5); List<List<Integer>> partitionList = Lists.partition(list, 2);//将一个大集合分成若干个小集合(分页) System.out.println(partitionList); } { List<String> list = Lists.newArrayList("a","b","c"); List<String> transformList = Lists.transform(list, x -> x.toUpperCase());//把某个集合转换成另外一个集合(流处理) System.out.println(transformList); } { List<Integer> list = Lists.newArrayList(3, 1, 2); List<Integer> reverseList = Lists.reverse(list);//颠倒顺序 System.out.println(reverseList); }
- collect google common Lists comcollect google common lists commons-collections commons-collection commons-collection序列collection commons commons-collections collections commons java commons-collections序列collections commons collectionutils collections4 collections commons lists completions possible lists bash-like intersection leetcode linked lists