public class Main {
4 public static void main(String[] args) {
5
6 int[] a = {9, 8, 7, 2, 3, 4, 1, 0, 6, 5};
7 Arrays.sort(a);
8 for(int i = 0; i < a.length; i ++) {
9 System.out.print(a[i]);
10 }
11 }
12
13 }
结果:0,1,2,3,4,5,6,7,8,9
本文提供了一个使用Java进行数组排序的简单示例。示例中定义了一个名为Main的公共类,并在main方法中创建了一个整数数组,通过调用Arrays类的sort方法对该数组进行了排序,最后遍历并打印了排序后的数组元素。
6905

被折叠的 条评论
为什么被折叠?



