zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    新生题目集
    C语言课程设计
    Java学习-8
    Java学习-7
    Java学习-6
    Java学习-5
    HTML学习
    Java学习-4
    强大的项目管理工具maven
    java学习-3
  • 原文地址:https://www.cnblogs.com/vector11248/p/7732769.html
Copyright © 2011-2022 走看看