直接上案例:
package com.itheima2;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class test01 {
public static void main(String[] args) {
List<Integer> list = new ArrayList<Integer>();
list.add(new Integer(14));
list.add(new Integer(17));
list.add(new Integer(01));
list.add(new Integer(0007));
list.add(new Integer(789));
list.add(new Integer(9999));
list.add(new Integer(1001));
Collections.sort(list);
for (Integer integer : list) {
System.out.println(integer);
}
System.out.println("最大数:"+list.get(list.size()-1));
}
}
打印输出:
1
7
14
17
789
1001
9999
最大数:9999