public class Exer1 {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
int i=10;
ArrayList list=new ArrayList();
while(i>0){
int num=scan.nextInt();
list.add(num);
i--;
}
Collections.sort(list);
Collections.reverse(list);
for(Object i1:list)
System.out.println(i1);
}
}
也可以在sort中定义一个定制排序Comparator