The difference between Collection and collections in Http://www.cnblogs.com/dashi/p/3597937.htmlJava 1, Java.util.Collection is aCollection Interface (a top-level interface of a collection Class)。 It provides a common interface method for basic manipulation of collection objects. The collection interface has many specific implementations in the Java class Library. The meaning of the collection interface is to provide a maximum unified operation for a variety of specific sets, and its direct inheritance interface has a list and set. Collection
├list
│├linkedlist
│├arraylist
│└vector
│└stack
└set 2, Java.util.Collections is a wrapper class (Tool class/helper Class). It contains a variety of information about collection operations.static Polymorphic method。 This classcannot instantiate, just like aa tool class, which is used to sort, search, and line Cheng the elements in the collection, serving the collection framework of Java.
code example:
?
| 1234567891011121314151617181920 |
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 class Library collection and collections (GO)