Java Map Interface

Source: Internet
Author: User

Map Interface Overview
* View API to know:
* Objects that map keys to values
* A map cannot contain duplicate keys
* Each key can be mapped to at most one value


The difference between the map interface and the collection interface
* Map is a double row, collection is a single row
* Map key is unique, collection sub-system set is unique
* The data structure value of the map collection is valid for the key, regardless of the value; The data structure of the collection collection is valid for the element

HashSet bottom is map; < key, value new object>

Features of the Map collection
* A: Add features
* V put (K key,v value): add element.
* If the key is stored for the first time, the element is stored directly, returning NULL
* If the key does not exist for the first time, replace the previous value with a value and return the previous value


* B: Delete function
* Void Clear (): Removes all key-value pair elements
* V Remove (Object key): Deletes the key value pair element according to the key, and returns the value


* C: Judging function
* Boolean ContainsKey (Object key): Determines whether the collection contains the specified key
* Boolean Containsvalue (Object value): Determines whether the collection contains the specified value
* Boolean isEmpty (): Determines whether the collection is empty


* D: Get function
* set<map.entry<k,v>> EntrySet ():
* V get (Object key): Gets the value according to the key
* set<k> KeySet (): Gets the collection of all the keys in the collection
* Collection<v> values (): Gets the collection of all values in the collection


* E: Length function
* int size (): Returns the number of key-value pairs in the collection

Here, the integer return value is the value that is saved before the data is placed, and is placed in an empty position before map.put;

Java Map Interface

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.