集册 Java实例教程 使用Arrays.sort方法对数组排序

使用Arrays.sort方法对数组排序

欢马劈雪     最近更新时间:2020-01-02 10:19:05

510
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
使用Arrays.sort方法对数组排序

import java.util.Arrays;
// 来自 时 代 J     a    v  a - nowjava.com

public class Main {


  public static void main(String[] args) {

    int[] lotto = new int[6];


    for (int i = 0; i < 6; i++)

      lotto[i] = (int) (Math.random() * 100) + 1;

    

    System.out.println(Arrays.toString(lotto));

    Arrays.sort(lotto);

    System.out.println(Arrays.toString(lotto));

  }


}