标签:plain 不能 keyword [] highlight .com 集合 元素 帮助
代码示例:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
import java.util.ArrayList;import java.util.Collections;import java.util.List;public class TestCollections { public static void main(String args[]) { //注意List是实现Collection接口的 List list = new ArrayList(); double array[] = { 112, 111, 23, 456, 231 }; for (int i = 0; i < array.length; i++) { list.add(new Double(array[i])); } Collections.sort(list); for (int i = 0; i < array.length; i++) { System.out.println(list.get(i)); } // 结果:23.0 111.0 112.0 231.0 456.0 }} |
java类库 collection与collections (转)
标签:plain 不能 keyword [] highlight .com 集合 元素 帮助
原文地址:http://www.cnblogs.com/elenz/p/6720390.html