/** * 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