Collections类中的方法都是静态的,所以直接类名.调用就可以了
ArrayList<String> al=new ArrayList<>();
al.add("a");
al.add("c");
al.add("d");
al.add("e");
al.add("f");
Collections.sort(al); //排序
System.out.println(al);
System.out.println(Collections.binarySearch(al, "c")); //二分查找法,返回c的索引
System.out.println(Collections.max(al)); // 获取最大值
Collections.reverse(al); //集合反转
System.out.println(al);
Collections.shuffle(al); //随机置换
System.out.println(al);