回覆列表
  • 1 # 小紅的甜心

    package com.king.test;

    import java.util.ArrayList;

    import java.util.Collections;

    import java.util.List;

    import java.util.Random;

    public class SortRandom {

    /**

    * @param args

    */

    public static void main(String[] args) {

    // TODO Auto-generated method stub

    int n = 10;

    List<Integer> list = new ArrayList<Integer>(n);

    int nTemp = 0;

    Random rd = new Random();

    for (int i = 0; i < n; i++) {

    nTemp = rd.nextInt(10000);

    list.add(nTemp);

    }

    for (Integer i : list) {

    System.out.print(i + " ");

    }

    System.out.println("\n-----After been sorted-----");

    Collections.sort(list);

    for (Integer i : list) {

    System.out.print(i + " ");

    }

    }

    }

  • 中秋節和大豐收的關聯?
  • 斗羅大陸魂環顏色?