时间:2022-10-06 12:00:18 | 栏目:JAVA代码 | 点击:次
Collection ├List │├LinkedList │├ArrayList │└Vector │ └Stack └Set
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 111 112 231 456 } }