LinkedHashSet与TreeSet

区别

类型 实现 特点
TreeSet hashMap、实现sortedSet接口 升序(基本类型……),自定义
LinkedHashSet HashSet 初始顺序

**注意点:
1.treeSet的排序和toString实际上是基于 插入的对象的 compareTo
和toString方法
换言之:就是插入的对象的类需要有comparable接口
2.set都不可以使用 collections.sort( List l)
你看我里面的参数哦,知道原因了吧
3.linkedHashSet的出现主要是为了规避 hashSet所造成的顺序混乱
和TreeSet因关联而造成的开销
**

原文地址:https://www.cnblogs.com/xieji233/p/6155627.html