Get features for Android (Java) Learning notes 103:map Collection

Source: Internet
Author: User

1  Packagecn.itcast_01;2 3 Importjava.util.Collection;4 ImportJava.util.HashMap;5 ImportJava.util.Map;6 ImportJava.util.Set;7 8 /*9 * Get Features:Ten * V get (Object key): Gets the value according to the key One * set<k> keySet (): Gets the collection of all the keys in the collection A * collection<v> values (): Gets the collection of all values in the collection -  */ -  Public classMapDemo2 { the      Public Static voidMain (string[] args) { -         //To create a collection object -map<string, string> map =NewHashmap<string, string>(); -  +         //creating elements and adding elements -Map.put ("Deng Chao", "Sun Li"); +Map.put ("Huang Xiaoming", "Angelababy yang"); AMap.put ("Jay Chou", "Jolin Tsai")); atMap.put ("Jacky Lau Wei", "Yang Mi"); -  -         //V get (Object key): Gets the value based on the key -System.out.println ("Get:" + map.get ("Jay Chou"))); -System.out.println ("Get:" + map.get ("Zhou Jie"));//returns null -System.out.println ("----------------------"); in  -         //set<k> KeySet (): Gets the collection of all the keys in the collection toSet<string> set =Map.keyset (); +          for(String key:set) { - System.out.println (key); the         } *System.out.println ("----------------------"); $ Panax Notoginseng         //collection<v> values (): Gets a collection of all values in the collection -collection<string> con =map.values (); the          for(String value:con) { + System.out.println (value); A         } the     } +}

Get features for Android (Java) Learning notes 103:map Collection

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.