The collection framework for Java

Source: Internet
Author: User

List and set under the 1.Collection interface

HashMap and TreeMap under the 2.Map interface

The difference between List and set. The List allows duplicate elements to exist, and set cannot have duplicate elements. Duplicate elements in set are not allowed to be determined by the hashcode and Equals methods, and equals are compared only when hashcode is the same.

The elements of the hashmap are unordered, and the elements inside the TreeMap are ordered (natural order).

It is necessary to implement the interface comparator or comparable to implement the ordering.

Comparable interface Implementation method

CompareTo (T o)

Comparatoe requires an interface implementation method
compare(T o1, T o2)
equals (Object obj)

The collection framework for Java

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.