package com.mengge.test;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class TestCollections {
public static void main(String[] args) {
List<String> list = new ArrayList<>();
for (int i = 0; i < 10; i++) {
list.add(String.valueOf(i));
}
System.out.println(list);
//[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
//随机排列数组中的元素
Collections.shuffle(list);
System.out.println(list);
//[1, 9, 5, 6, 4, 3, 8, 2, 7, 0]
//反转
Collections.reverse(list);
System.out.println(list);
//[1, 2, 3, 9, 7, 0, 6, 4, 8, 5]
//重新正向排序
Collections.sort(list);
System.out.println(list);
//[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
}
}