Collections.静态方法()

简介: <Comparable<? super Comparable<? super T>>> void java.util.Collections.sort(List<Comparable<? super Comparable<? super T>>> list) 升序排列List中的元素。 <T>

<Comparable<? super Comparable<? super T>>> void java.util.Collections.sort(List<Comparable<? super Comparable<? super T>>> list)

升序排列List中的元素。


<T> void java.util.Collections.sort(List<Student> list, Comparator<? super T> c)

使用Comparator升序排列List中的元素。

static int frequency(Collection<?> c, Object o)
返回集合中某元素的出现次数。

T max(Collection<? extends T> coll)
返回最大的元素。

static <T> T min(Collection<? extends T> coll, Comparator<? super T> comp)
返回最小的元素。

static <T> Comparator<T>  reverseOrder()
返回一个Comparator,行为与原Comparable相反。

static void reverse(List<?> list)
反转List中的元素。
Reverses the order of the elements in the specified list.

static void rotate(List<?> list, int distance)
旋转list中的元素。即list=[t, a, n, k, s]. After invoking Collections.rotate(list, 1) (or Collections.rotate(list, -4)), list will comprise [s, t, a, n, k].

static void shuffle(List<?> list)
对list元素乱序重排,洗牌的效果。

static <T> int binarySearch(List<? extends Comparable<? super T>> list, T key)
要求List中元素已经升序排列。找不到返回负数。

<T> List<T> java.util.Collections.nCopies(int n, T o)
返回含有指定对象n份拷贝的不可变list。注意是浅拷贝。

目录
相关文章
|
4月前
|
存储 Java API
Scanner类、Random类、ArrayList类
Scanner类、Random类、ArrayList类
|
6月前
|
Java
Map集合详解及Collections方法和Arrays方法
Map集合详解及Collections方法和Arrays方法
39 0
|
8月前
|
安全 Java 索引
collections类
collections类
28 0
|
7月前
|
存储 Java
Java集合Collections工具类
Java集合Collections工具类
43 0
|
7月前
Arrays类中的常见方法
导包 常见方法的使用 1.Arrays.toString() 2.Arrays.fill() 3.Arrays.sort() 4. Arrays.equals() 5.Arrays.binarySearch() 6.Arrays.copyOf() 和Arrays.copyOfRange()
58 1
|
8月前
Collections工具类
Collections工具类
20 0
|
10月前
|
存储 Java 索引
Arrays Collections工具类
Arrays Collections工具类
|
12月前
|
安全 Java API
【JavaEE】Thread 类及常用方法
哈喽,大家好~我是保护小周ღ,本期为大家带来的是 Java 多线程的 Thread 类,讲述了 Thread 类的常用方法及常用属性,例如:线程的 name, 如何启动线程,终止线程,等待线程…… 更多精彩敬请期待:保护小周ღ *★,°*:.☆( ̄▽ ̄)/$:*.°★* ‘
集合Collections工具类
针对集合进行操作的工具类。