Java basic review: map interface

Source: Internet
Author: User

Map indicates the ing relationship, which is a pair of (Key, value) relationships.

Duplicate key values are not allowed. The relationship between key and value is many-to-one, that is, each value corresponds to a unique key.

Map. entry is the internal structure of the map interface, which is used to save key-value content.

Import Java. util. hashmap; import Java. util. map; import Java. util. set; public class mapdemo {public static void main (string [] ARGs) {map = new hashmap (); map. put (1, "Well"); map. put (2, "Lily"); map. put (3, "Tom"); system. out. println (MAP);/** Boolean containskey (Object key) If this ing contains the ing relationship of the specified key, true * Boolean containsvalue (object Value) is returned) if this ing maps one or more keys to a specified value, true * object get (Object key) is returned to return the value mapped by the specified key. If this ing If the ing relationship does not contain the key, null * object remove (Object key) is returned. If a key ing relationship exists, it is removed from the ing (optional) * Set entryset () returns the set view of the ing relationships contained in the ing. */Set entrys = map. entryset (); For (Object object: entrys) {system. Out. println (object );}}}

 

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.