📅  最后修改于: 2020-11-14 06:14:14             🧑  作者: Mango
java.util.Collections类仅由对集合进行操作或返回集合的静态方法组成。以下是有关Collections的重点-
它包含对集合“包装器”进行操作的多态算法,该算法返回由指定集合支持的新集合。
如果提供给它们的集合或类对象为null,则此类的所有方法都将引发NullPointerException。
以下是java.util.Collections类的声明-
public class Collections
extends Object
以下是java.util.Collections类的字段-
静态列表EMPTY_LIST-这是空列表(不可变)。
静态映射EMPTY_MAP-这是空映射(不可变)。
静态集EMPTY_SET-这是空集(不可变)。
Sr.No. | Method & Description |
---|---|
1 | static This method adds all of the specified elements to the specified collection. |
2 | static This method returns a view of a Deque as a Last-in-first-out (Lifo) Queue. |
3 | static This method searches the specified list for the specified object using the binary search algorithm. |
4 | static This method searches the specified list for the specified object using the binary search algorithm. |
5 | static This method returns a dynamically typesafe view of the specified collection. |
6 | static This method returns a dynamically typesafe view of the specified list. |
7 | static This method returns a dynamically typesafe view of the specified map. |
8 | static This method returns a dynamically typesafe view of the specified set. |
9 | static This method returns a dynamically typesafe view of the specified sorted map. |
10 | static This method returns a dynamically typesafe view of the specified sorted set. |
11 | static This method copies all of the elements from one list into another. |
12 | static boolean disjoint(Collection> c1, Collection> c2)
This method returns true if the two specified collections have no elements in common. |
13 | static This method returns the empty list (immutable). |
14 | static This method returns the empty map (immutable). |
15 | static This method returns the empty set (immutable). |
16 | static This method returns an enumeration over the specified collection. |
17 | static This method replaces all of the elements of the specified list with the specified element. |
18 | static int frequency(Collection> c, Object o)
This method returns the number of elements in the specified collection equal to the specified object. |
19 | static int indexOfSubList(List> source, List> target)
This method returns the starting position of the first occurrence of the specified target list within the specified source list, or -1 if there is no such occurrence. |
20 | static int lastIndexOfSubList(List> source, List> target)
This method returns the starting position of the last occurrence of the specified target list within the specified source list, or -1 if there is no such occurrence. |
21 | static This method returns an array list containing the elements returned by the specified enumeration in the order they are returned by the enumeration. |
22 | static This method returns the maximum element of the given collection, according to the natural ordering of its elements. |
23 | static This method returns the maximum element of the given collection, according to the order induced by the specified comparator. |
24 | static This method Returns the minimum element of the given collection, according to the natural ordering of its elements. |
25 | static This method returns the minimum element of the given collection, according to the order induced by the specified comparator. |
26 | static This method returns an immutable list consisting of n copies of the specified object. |
27 | static This method returns a set backed by the specified map. |
28 | static This method replaces all occurrences of one specified value in a list with another. |
29 | static void reverse(List> list)
This method reverses the order of the elements in the specified list. |
30 | static This method returns a comparator that imposes the reverse of the natural ordering on a collection of objects that implement the Comparable interface. |
31 | static This method returns a comparator that imposes the reverse ordering of the specified comparator. |
32 | static void rotate(List> list, int distance)
This method rotates the elements in the specified list by the specified distance. |
33 | static void shuffle(List> list)
This method randomly permutes the specified list using a default source of randomness. |
34 | static void shuffle(List> list, Random rnd)
This method randomly permute the specified list using the specified source of randomness. |
35 | static This method returns an immutable set containing only the specified object. |
36 | static This method returns an immutable list containing only the specified object. |
37 | static This method returns an immutable map, mapping only the specified key to the specified value. |
38 | static This method sorts the specified list into ascending order, according to the natural ordering of its elements. |
39 | static This method sorts the specified list according to the order induced by the specified comparator. |
40 | static void swap(List> list, int i, int j)
This method swaps the elements at the specified positions in the specified list. |
41 | static This method returns a synchronized (thread-safe) collection backed by the specified collection. |
42 | static This method returns a synchronized (thread-safe) list backed by the specified list. |
43 | static This method returns a synchronized (thread-safe) map backed by the specified map. |
44 | static This method returns a synchronized (thread-safe) set backed by the specified set. |
45 | static This method returns a synchronized (thread-safe) sorted map backed by the specified sorted map. |
46 | static This method returns a synchronized (thread-safe) sorted set backed by the specified sorted set. |
47 | static This method returns an unmodifiable view of the specified collection. |
48 | static This method returns an unmodifiable view of the specified list. |
49 | static This method returns an unmodifiable view of the specified map. |
50 | static This method returns an unmodifiable view of the specified set. |
51 | static This method returns an unmodifiable view of the specified sorted map. |
52 | static This method returns an unmodifiable view of the specified sorted set. |
此类从以下类继承方法-