publicclassMain { publicstaticvoidmain(String[] args) { Listlist= Arrays.asList("one Two three Four five six one three Four".split(" ")); System.out.println(list); System.out.println("最大值: " + Collections.max(list)); System.out.println("最小值: " + Collections.min(list)); } }
以上代码运行输出结果为:
1 2 3
[one, Two, three, Four, five, six, one, three, Four] 最大值: three 最小值: Four