Collections类常用方法
Collections类是Java中针对集合类的一个工具类,其中提供一系列静态方法。
1. sort(Comparator<? super E>):void List 对集合中的元素排序
2.reverse(List<?>):void 反转集合中的元素
3.shuffle(List<?>):void 打乱元素中的元素
4.fill(List<? super T>,T):void 用T元素替换掉集合中的所有的元素
5.copy(List<? super T>,List<? extend T>):void 复制并覆盖相应索引的元素
6.min/max(Collection<? extends T>):T 找到集合中最大/小的元素
7.swap(List<?>,int,int):void 交换集合中指定元素索引的位置
8.rotate(List<?>,int):void 集合中的元素向后移m个位置,在后面被遮盖的元素循环到前面来(负数向左移动,正数向右移动)
9.indexOfSubList(List<?>,List<?>):int / lastIndexOfSubList(List<?>,List<?>):int 找出参数2在参数1第一次出现的位置
10.replaceAll(List,T,T):boolean 替换成指定的元素
11.synchronizedXxx方法 可以将某集合转化成线程安全的容器之后再使用
12.unmodifiableCollection(Collection<? extends T>):Collection 将集合变为不可修改(只读)