1 import java.util.ArrayList; 2 import java.util.Collections; 3 import java.util.List; 4 5 public class 集合工具类 { 6 public static void main(String[] args) { 7 List<String> list = new ArrayList<String>(); 8 list.add("张三"); 9 list.add("李四"); 10 list.add("王五"); 11 System.out.println(list); 12 //反转 13 Collections.reverse(list); 14 System.out.println(list); 15 //打乱集合 16 Collections.shuffle(list); 17 System.out.println(list); 18 //排序 19 Collections.sort(list); 20 System.out.println(list); 21 } 22 }
原文:https://www.cnblogs.com/java-jiangtao-home/p/9374723.html