java数组排序

2019年2月13日23:27:07 发表评论 975 views
/**
 * Created by xabcd on 2019/2/13.
 */
import java.util.*;
public class java_sort {
    public static void main(String args[])
    {
        int a[]={4,32,45,32,65,32,2};
        System.out.print("数组排序前为:");
        for(int i=0;i<a.length;i++)
            System.out.println(a[i]);
        Arrays.sort(a);
        System.out.print("数组排序后为:");
        for(int i=0;i<a.length;i++)
            System.out.println(a[i]);
    }
}





结果:
数组排序前为:4
32
45
32
65
32
2
数组排序后为:2
4
32
32
32
45
65

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: