Java-map interface

Source: Internet
Author: User
(1) Three kinds of collection Views:key sets, value sets, Key-value
(2) Order: An iterator (interators) returns the order of the map elements, like TreeMap, but HashMap does not
(3) The implementation class of the map must provide two constructs:
1. Parameterless constructor for constructing an empty map
Public HashMap () {
        this.loadfactor = default_load_factor;
        threshold = (int) (default_initial_capacity * default_load_factor);
        Table = new Entry[default_initial_capacity];
        Init ();
    }

2. A constructor with a unique map parameter to construct a map with the same key value pair
  Public HashMap (map<. Extends K,? extends v> m) {This
        (Math.max ((int) (M.size ()/Default_load_factor) + 1,
                      default_initial_capacity), default_load_factor);
        Putallforcreate (m);
    }

Used to copy any map
Although an interface cannot provide a constructor, it is not mandatory to specify that the implementation class must contain both constructors, but all implementation classes contain
(4) A free call to methods in the object class, such as Equals and hashcode


Attention:
(1) Key cannot be duplicated, a key corresponds to a value of up to
(2) The type of key should be noted that the map itself is not allowed as a key type

Note that the method definitions for equals and hashcode are problematic, and the override needs to be synchronized

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.