List的排序是通过Collections.sort(List)来排序的。
集合 |
排序 |
遍历 |
添加 |
删除 |
List: ArrayList,LinkList |
Collections.sort(List) |
get(i) |
add() |
remove() |
Set: HashSet,TreeSet |
TreeSet:要实现Comparable接口并实现他的compareTo方法。add的时候会自动排列。 |
Iterator<E> ws = workers.iterator(); ws.hasNext(); ws.next(); |
add() |
remove() |
Map: HashMap,TreeMap |
TreeMap已经实现SortedSet接口 |
Set s = map.keySet(); Iterator遍历 |
remove() clear() |
数组的工具类:Arrays
集合的工具类:Collections