public class BOKE {
public static void main(String[] args) {
Integer a[]={12,33,21,5,6,18};
//进行升序排列
Arrays.sort(a);
System.out.println(Arrays.toString(a));
//进行降序排列方法1:
for(int i=a.length-1;i>=0;i--){
System.out.print(a[i]+",");
}
//进行降序排列方法2:
List list=new ArrayList();
list=Arrays.asList(a);
Collections.sort(list);
Collections.reverse(list);
System.out.println("\n"+list);
}
}
时间: 2024-12-20 14:14:15