Java集合复习--ArrayList

 1 import java.util.*;
 2 public class matrixReshape {
 3 
 4 
 5     public static void  main(String[] args){
 6         Scanner sc = new Scanner(System.in);
 7         ArrayList arrayList = new ArrayList();
 8         while(sc.hasNextInt())
 9         {
10             arrayList.add(sc.nextInt());
11         }
12         arrayList.sort(com.reversed());//倒序输出
13         System.out.println(arrayList);
14     }    
15     public static final Comparator<Integer> com = new Comparator<Integer>()//定义Comparator借口
16     {
17         public int compare(Integer a,Integer b)
18         {
19                 return a.compareTo(b);
20         }
21     };
22 
23 
24 }

 

posted @ 2017-10-25 22:14  vector11248  阅读(115)  评论(0编辑  收藏  举报