How to check that if same key alreay exists in Hashtable
Post by:ram gaurav
, Ranch Hand
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
Post by:Peter Chase
, Ranch Hand
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.
Post by:ram gaurav
, Ranch Hand
Thanks a lot
Post by:autobot
Humans and their filthy friendship brings nothing but trouble. My only solace is this tiny ad:
Thread Boost - a very different sort of advertising