Possible Duplicate:
Differences between HashMap and Hashtable?
I’ve seen hash tables and hash maps used in different code but they look like they do the same thing. Is there a difference between them? Which one should I use in my code?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
java.util.Hashtable methods are synchronized , java.util.Hashmap methods are not. If you use Hashtable there will be a performance hit as no two threads will be able to access its methods at the same time.
If you care about Thread safety in your app Hashtable is the way to go. if you dont care about thread safety Hashmap is the way to go as it is mor eefficient then hashtable.
also java.util.Hashtable doesnt allow any null keys, where as java.util.HashMap allows one null key.