A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© Moonboy2014 中级黑马   /  2014-6-21 00:16  /  2063 人查看  /  11 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

import java.util.*;
class Person
{
        private String name;
        private int age;
        Person(String name,int age)
        {
                this.name = name;
                this.age = age;
        }
        public int hashCode()
        {
                return name.hashCode()+age;
        }
        public boolean equals(Object obj)
        {
                if(!(obj instanceof Person))
                        throw new RuntimeException("类型不匹配");
                Person p = (Person)obj;
                return this.name.equals(p.name) && this.age == p.age;
        }
        public String getName()
        {
                return name;
        }
        public int getAge()
        {
                return age;
        }
        public String toString()
        {
                return name+"::"+age;
        }
}
class HashMapDemo
{
        public static void main(String[] args)
        {

                Map<Person,String> map = new HashMap<Person,String>();
                map.put(new Person("zhagnsan",20),"beijing");
                map.put(new Person("zhangsan1",15),"nanjing");
                map.put(new Person("zhangsan2",21),"wuhan");
                map.put(new Person("zhangsan3",40),"tianjing");

                Set<Map.Entry<Person,String>> entrySet = map.entrySet();
                Iterator<Map.Entry<Person,String>> it = entrySet.iterator();
                while(it.hasNext())
                {
                        Map.Entry<Person,String> me = it.next();
                        Person key = me.getKey();
                        String value = me.getValue();
                        System.out.println(key+"::"+value);
                }
        }
}
以上代码去掉哪一个部分编译会报81个错误?

11 个回复

倒序浏览
楼主果然无聊!
回复 使用道具 举报
~~~~~~~~~~~~~~~~~~~~~~~
回复 使用道具 举报
果然无聊、、、、
回复 使用道具 举报
。。。。。。。。
回复 使用道具 举报
最后一句话的确很无聊。。。。
回复 使用道具 举报
写的时候一不小心误删了只占一个空格的东西,结果编译的时候提示错误刷屏了,当时给我震撼的。。。
回复 使用道具 举报
{:2_31:}{:2_31:}{:2_31:}{:2_31:}{:2_31:}{:2_31:}
回复 使用道具 举报
我去,好无聊
回复 使用道具 举报
你确实够无聊的 !
回复 使用道具 举报
class Person
回复 使用道具 举报
。。。。。。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马