Forums Register Login
How to check that if same key alreay exists in Hashtable

Like , we make Hashtable t = new Hashtable();


then will it calls the equals methord to check that the key already exists in that or what methord it uses for this.

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.
Thanks a lot
Wanna see my flashlight? How about this tiny ad?
Programmatically Create PDF Using Free Spire.PDF with Java

This thread has been viewed 1335 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jan 22, 2019 20:33:40.