import java.util.*;
public class Test {
public static void main(String[] args) {
Random random = new Random();
List list = new ArrayList();
for(int i=0; i<10; i++){
int randomInt = random.nextInt(90) + 10;
list.add(new Integer(randomInt));
}
System.out.println(list.toString());
Collections.sort(list);
System.out.println(list.toString());
}
}
允许重复的示例。如不允许有重复,可考虑用treeSet,具体不说了。
温馨提示:内容为网友见解,仅供参考