Common methods of Map collections in Java

Source: Internet
Author: User
Tags set set

The difference between a map collection and a collection collection

The map collection is a key and value, and the collection collection is only value.

Collection The bottom of the collection is also a key and value, just hidden.

v put(K key, v value)

Adds a key to the map collection that is key,value as value and returns null if the addition succeeds, otherwise returns value.

This means that the key in the map collection cannot be duplicated, which is similar to the elements in the set set that cannot be duplicated, but the value in the Map collection can be duplicated.

void putall(Map<? extends K,? extends V> m)

Adds all elements of the specified collection to the Map collection

void Clear()

Delete all the key values in the Map collection

boolean containskey(Object key)

The check out map collection contains no elements of key key and returns true if any, otherwise false.

boolean containsvalue(Object value)

The check out map collection has no element that contains value value and returns True if any, otherwise false.

Set<map.entry<K,V>> entryset()

Returns a map to a set set, returned to the set in the form of Key=value in the Map collection.

boolean equals(Object o)

Determines whether the elements of the two set set are the same

The lower level also overrides the Equals method

When we look at the HashMap collection, we do not find the Equals method, so we go to his parent class.

V get(Object key)

Gets the value of the corresponding element according to the key of the element in the Map collection

int hashcode()

Returns the hash code value of the Map collection

boolean isEmpty()

Checks out if there are elements in the map collection, returns True if none, and returns False if there are elements

Set<K> keySet()

Returns all keys in the map collection

V Remove(Object key)

Remove the key as the key value of the element

int size()

Returns the number of elements in the map collection

Collection<V> values()

Returns all the value in the Map collection to a collection collection

Common methods of Map collections in Java

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.