Java集合中Collections工具类总结
Collections工具类 Collections 是一个操作 Collection(Set、 List )和 Map 等集合的工具类 Collection和Collections的区别? Collection是用来存储单列数据的集合接口,常用子接口有List和Set Collections是操作Collection的工具类。 常用方法 排序操作: reverse(List): 反转 List 中元素的顺序 shuffle(List): 对 List 集合元素进行随机排序 sort(List): 根据元素的自然顺序对指定 List 集合元素按升序排序 sort(List, Comparator): 根据指定的 Comparator 产生的顺序对 List 集合元素进行排序 swap(List, int, int): 将指定 list 集合中的 i 处元素和 j 处元素进行交换 查找和替换: Object max(Collection): 根据元素的自然顺序,返回给定集合中的最大元素 Object max(Collection, Comparator): 根据 Comparator 指定的顺序,返回给定集合中的最大元素 Object min(Collection) Object min(Collection, Comparator) int frequency(Collection