标签:shuffle alt inf new 查找 shm 实现 hashset 工具类
方法:
addAll案例:
private static void addAll() { ArrayList<Integer> list = new ArrayList<>(); list.add(1); list.add(2); list.add(3); System.out.println("list1"+list); Collections.addAll(list, 4, 5, 6); System.out.println("list2"+list); } //list1[1, 2, 3] //list2[1, 2, 3, 4, 5, 6]
排序功能:
/** * 取字符串第一个字符按降序排列 */ private static void collecyionsSort() { ArrayList<String> list = new ArrayList<>(); Collections.addAll(list, "哈哈", "哭哭", "嘻嘻"); Collections.sort(list, new Comparator<String>() { @Override public int compare(String o1, String o2) { return o2.charAt(0)-o1.charAt(0); } }); System.out.println("list = " + list); } // list = [嘻嘻, 哭哭, 哈哈]
标签:shuffle alt inf new 查找 shm 实现 hashset 工具类
原文地址:https://www.cnblogs.com/chenglei0718/p/11441718.html