初学者求教,一个关于hash地图的有关问题

菜鸟求教,一个关于hashmap的问题
现在有两个线程
一个线程创建一个group对象,并给他创建的一相应的key
把他们装入一个hashmap里
代码如下
Java code
 group=new Group(str_str[1]);
                             //将这个线程类加入到group的clientthread里
                             group.clientthread.add(this);
                             //打印group的内容
                             System.out.println(group);
                             //生成这个group对象的一个相应的key
                             GroupKey gk=new GroupKey(str_str[1]);
                             //打印key的值
                             System.out.println(gk);
                            //把这一对键值对加入到serverThread的grouphashmap里
                            serverThread.grouphashmap.put(gk,group);
                            //打印grouphashmap的内容
                            System.out.print(serverThread.grouphashmap);                                    


打印出的内容为
Group@253498
GroupKey@1c0
{GroupKey@1c0=Group@253498}

第二个线程要用一个key找到对应的值
Java code
//首先打印grouphashmap的内容
                                System.out.println(serverThread.grouphashmap);
                                //生成一个groupkey和gk一样
                                GroupKey gk1=new GroupKey(str_str[1]);
                                //打印一下gk1
                                System.out.println(gk1);
                                //在grouphashmap里得到gk1所对应的value
                                 System.out.println(serverThread.grouphashmap.get(gk1));//false

创建的gk1和第一个线程的gk是一样的我原本是要找到第一个线程加进hashmap里的group
可是打印结果很奇怪
{GroupKey@1c0=Group@253498}
GroupKey@1c0
null

打印出的group对象和kgroupkey对象都和我放进去的一样
可是在用hashmap的get()方法取group的对象的时候
却是null
这是为什么呢,菜鸟第一次用hashmap,希望各位不吝赐教。

------解决方案--------------------
GroupKey 的hashCode方法和equals方法是怎么写的

“生成一个groupkey和gk一样”这两个对象的hashCode是否一样,调用equals是否相等
------解决方案--------------------
我用其它对象代替Group和Hashmap就正常的,第一个程序完整的给出来,就可以试下看看了。
按理只要gk1.equals(gk) == true 就能得到value了



public V get(Object key)
Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key. 
More formally, if this map contains a mapping from a key k to a value v such that (key==null ? k==null : key.equals(k)), then this method returns v; otherwise it returns null. (There can be at most one such mapping.) 

A return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases. 


------解决方案--------------------
public boolean equals(Object o)
{
GroupKey g=(GroupKey)o;
return groupname==g.groupname; 改成 groupname.equals(g.groupname);
}