| Author |
How to check that if same key alreay exists in Hashtable
|
ram gaurav
Ranch Hand
Joined: Mar 29, 2006
Posts: 208
|
|
HI Like , we make Hashtable t = new Hashtable(); t.put("a","A"); t.put("a","B"); then will it calls the equals methord to check that the key already exists in that or what methord it uses for this. Thanks Regards Gaurav
|
 |
Peter Chase
Ranch Hand
Joined: Oct 30, 2001
Posts: 1970
|
|
You can use containsKey() to check if the key is there beforehand. Or you can look at the return value from put() to see what, if any, value was replaced by your put(). By the way, unless this is legacy code that you cannot change, do not use Hashtable. It is an old class with pointless, slow synchronisation. Use HashMap instead.
|
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.<br /> <br />#:^P
|
 |
ram gaurav
Ranch Hand
Joined: Mar 29, 2006
Posts: 208
|
|
|
Thanks a lot
|
 |
 |
|
|
subject: How to check that if same key alreay exists in Hashtable
|
|
|