一、核心区别Collection是接口是所有单值集合的跟接口List、Set、Queue都继承它Collections是工具类全是静态方法意味着只需要调用即可不需要创建对象专门是用来操作Collection集合提供各种方便操作排序、反转、查找......特性CollectionCollections类型接口interface工具类final class作用定义集合的规范增删改查提供操作集合的静态方法子类 / 实现List、Set、Queue无子类不能实例化使用方式实现类创建对象使用直接调用静态方法类名。方法二、Collection接口1.继承体系Collection (根接口) ├─ List 有序、可重复、有索引 ├─ Set 无序、不可重复、无索引 └─ Queue 队列、先进先出2.常用方法Collection定义了集合最基础的操作// 添加元素 boolean add(E e); // 批量添加 boolean addAll(Collection? extends E c); // 删除指定元素 boolean remove(Object o); // 判断是否包含 boolean contains(Object o); // 清空集合 void clear(); // 获取元素个数 int size(); // 判断是否为空 boolean isEmpty(); // 转数组 Object[] toArray(); // 迭代器遍历集合 IteratorE iterator();3.常用实现类ListArrayList、LinkedList、VectorSetHashSet、LinkedHashSet、TreeSetQueueLinkedList、PriorityQueue三、Collections工具类不能创建对象所有方法都是static静态方法直接调用1.常用静态方法1排序这里的comparator之前有提到过哦在lambda那篇文章里// 自然排序元素必须实现Comparable Collections.sort(list); // 自定义排序传入Comparator Collections.sort(list, Comparator.comparing(...) );2查找// 二分查找必须先排序 int index Collections.binarySearch(list, key); ListInteger list new ArrayList(); //获取最大值 Integer max Collections.max(list); //获取最小值 Integer min Collections.min(list);3修改// 反转集合 Collections.reverse(list); // 随机打乱 Collections.shuffle(list); // 替换所有元素 Collections.fill(list, obj); // 交换两个索引位置 Collections.swap(list, i, j);