1 Introduction
java.utils.Collections is a collection tool class, used to operate collections.
2 Commonly used API
public static <T> boolean addAll(Collection<T> c, T... elements): Add some elements to the collection.
public static void shuffle(List<?> list): Shuffle the order, shuffle the order of the collection.
public static <T> void sort(List<T> list): Sort the elements in the collection according to the default rules.
3 use
Demo01 {
(String[] args) {
ArrayList<String> arrayList =
ArrayList<>()
Collections. addAll (arrayList
)
System.
.println(
+arrayList)
Collections. shuffle (arrayList)
System.
.println(
+arrayList)
Collections. shuffle (arrayList)
System.
.println(
+arrayList)
Collections. sort (arrayList)
System.
.println(
+arrayList)
}
}
For more technical information, please pay attention to: gzitcast