Today, look at the Java pen Test, found that there is such a problem, compare collection and collections differences. Keep a record of the differences here.
1, Java.util.Collection is a collection interface . 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 collections.
Collection
├list
│├linkedlist
│├arraylist
│└vector
│└stack
└set
2, Java.util.Collections is a packaging class. It contains a variety of static polymorphic methods related to set operations. This class cannot be instantiated , just like a tool class that serves the Java collection framework.
Java code 650) this.width=650; "class=" star "src=" Http://pengcqu.iteye.com/images/icon_star.png "alt=" Favorite Code "style=" border:0px; "/>
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Public class testcollections {
Public Static void Main (String args[]) {
//Note that the list is implemented with the collection interface
List List = new ArrayList ();
double array[] = { 111, 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));
}
//Result: 23.0 111.0 112.0 231.0 456.0
}
}
The difference between collection and collections in Java