标签:hat 变化 工具 system lists asList 集合 iss like
单列集合的工具类
// Lists // 创建集合 List<String> list1 = Lists.newArrayList(); List<String> list2 = Lists.newArrayListWithCapacity(8); List<String> list3 = Lists.newArrayListWithExpectedSize(8); // 集合分片 List<Integer> list4 = Lists.newArrayList(1, 2, 3, 4, 5); // [[1, 2], [3, 4], [5]] List<List<Integer>> partition = Lists.partition(list4, 2); System.out.println(partition); //新建集合 String str1 = " I love you"; String[] str2 = {" I like you", "I miss you"}; List<String> list5 = Lists.asList(str1, str2); // [ I love you, I like you, I miss you] System.out.println(list5); str2[1] = " I hate you"; // [ I love you, I like you, I hate you] 都会变化 System.out.println(list5); //反转集合中元素 // [ I hate you, I like you, I love you] List<String> list6 = Lists.reverse(list5); System.out.println(list6);
标签:hat 变化 工具 system lists asList 集合 iss like
原文地址:https://www.cnblogs.com/zwy008/p/14826742.html