Collections工具类
1 import java.util.Collections; 2 import java.util.LinkedList; 3 import java.util.List; 4 5 public class Test19 6 { 7 public static void main(String[] args) 8 { 9 List list=new LinkedList();//多态 10 for(int i=0;i<9;i++)//循环添加值 11 { 12 list.add("a"+i); 13 } 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 Collections.reverse(list); 23 System.out.println("逆序排列:"+list); 24 } 25 }