Java class Library collection and collections

Source: Internet
Author: User

The difference between Collection and collections in Http://www.cnblogs.com/dashi/p/3597937.htmlJava 1, Java.util.Collection is a Collection 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 class cannot instantiate, just like a a 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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.