Big Data Java Foundation 11th day Job

Source: Internet
Author: User

The second question:public class person {    private string name;         public person () {             }    public person (String name) {         super ();        this.name = name;     }        public string getname () {         return this.name;    }}public  Class dog {    private string name;    public  dog () {            }     Public dog (string name) {        super ();         this.Name = name;    }    public string getname () {         return this.name;    }}import  Java.util.map;import java.util.hashmap;import java.util.map.entry;import java.util.list;import  java.util.arraylist;public class hashdemo {    public static  void main (String[] args)  {        map<person, Dog> hashmap = new hashmap<person,dog> ();         List<Person> list = new ArrayList<Person> ();                 person person_obj =  null;        for (int i=0;i<100;i++) {             person_obj = new person ("Person_name"  + i);             hashmap.put (Person_obj, new dog ("Dog_name"  +  i));             list.add (person_obj);         }                 //keyset        for (Person p :  hashmap.keyset ()) {             System.out.println (P.getname ()  +  "---"  + hashmap.get (P). GetName ());         }                 //EntrySet        for  (entry<person,  Dog> entry : hashmaP.entryset ())  {            system.out.println (Entry.getkey (). GetName ()  +  "---"  + entry.getvalue (). GetName ());         }                 for (person pl : list) {             hashmap.remove (PL);        }         system.out.println ("------------");         System.out.println (Hashmap.size ());     }}


This article is from the "Forest Sensitive" blog, please be sure to keep this source http://senlinmin.blog.51cto.com/6400386/1774754

Big Data Java Foundation 11th day Job

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.