public static void main(String[] args) {
List<Integer> list=new ArrayList<Integer>();
//产生10以内的随机数
int num = 10;
for(int i=1;i<=num;i++){
list.add(i);
}
for(Object o : list){
System.out.println(o);
}
System.out.println("++++++++++++++++++++++++++++++++++++");
Collections.sort(list, new Comparator<Integer>() {
@Override
public int compare(Integer o1, Integer o2) {
if (o1> o2) {
return -1;
} else if (o1 < o2) {
return 1;
}
return 0;
}
});
for(Object o : list){
System.out.println(o);
}
}