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);
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 + " ");
}
}
}