HashSet /LinkedHashSet/TreeSet排序的不同
2009-12-14 00:17
274 查看
HashSet set1 = new HashSet(Arrays.asList("b c e f g a".split(" "))); LinkedHashSet set2 = new LinkedHashSet(Arrays.asList("b c e f g a".split(" "))); SortedSet set3 = new TreeSet(Arrays.asList("b c e f g a".split(" "))); System.out.println(set1); System.out.println(set2); System.out.println(set3);
输出结果为:
[f, g, e, b, c, a]
[b, c, e, f, g, a]
[a, b, c, e, f, g]
HashSet按Hash函数排序
LinkedHashSet按插入顺序排序
TreeSet按字母顺序排序
相关文章推荐
- HashSet /LinkedHashSet/TreeSet排序的不同
- JAVA菜鸟入门(17) 有排序的TreeSet和无排序的HashSet, LinkedHashSet
- HashSet vs TreeSet vs LinkedHashSet
- 黑马程序员_JavaSE基础17 之 集合框架 Vector LinkedList ArrayList HashSet LinkedHasSet TreeSet
- [2017.11.12]Set&HashSet&LinkedHashSet&TreeSet&模拟用户
- HashSet TreeSet LinkedHashSet 区别
- HashSet vs. TreeSet vs. LinkedHashSet
- HashSet vs. TreeSet vs. LinkedHashSet
- Collection List Set SortedSet ArrayList LinkedList HashSet LinkedHashSet TreeSet的认识及用法
- Java基础 集合框架 共性方法 迭代器 ArrayList LinkedList Vector HashSet TreeSet
- java中Collection/Collections;List/Set/Map;ArrayList/Vector/LinkedList;HashSet/HashMap/TreeSet/TreeMap
- Java集合中的ArrayList LinkedList HashSet TreeSet HashMap TreeMap 的区别
- HashSet vs. TreeSet vs. LinkedHashSet
- HashSet LinkedHashSet TreeSet
- java集合类(七)Set之LinkedHashSet&TreeSet
- hashSet linkedHashSet treeSet 一点区别
- day17 集合框架 LinkedHashSet TreeSet Map 泛型
- HashSet vs. TreeSet vs. LinkedHashSet
- JDK源码学习(6)-java.util.HashSet & java.util.LinkedHashSet & java.util.TreeSet
- JDK源码学习笔记——HashSet LinkedHashSet TreeSet