注意问题:jdk版本 。用了1.6的,reverse()方法排序乱掉了。
@Test
public void testCollection() {
List<Integer> list = new ArrayList<Integer>();
list.add(25);
list.add(1);
list.add(7);
list.add(36);
list.add(24);
list.add(5);
list.add(4);
List<Integer> tempList =new ArrayList<Integer>();
tempList.add(100);
tempList.add(100);
tempList.add(100);
tempList.add(100);
tempList.add(100);
tempList.add(100);
tempList.add(100);
System.out.println("正序===========");
Collections.sort(list);
for (Integer integer : list) {
System.out.println(integer);
}
System.out.println("倒序===========");
Collections.reverse(list);
for (Integer integer : list) {
System.out.println(integer);
}
System.out.println("copy========");
Collections.copy(list,tempList);
for (Integer integer : tempList) {
System.out.println(integer);
}
}
