Share
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.
There are several differences between
HashMapandHashtablein Java:Hashtableis synchronized, whereasHashMapis not. This makesHashMapbetter for non-threaded applications, as unsynchronized Objects typically perform better than synchronized ones.Hashtabledoes not allownullkeys or values.HashMapallows onenullkey and any number ofnullvalues.One of HashMap’s subclasses is
LinkedHashMap, so in the event that you’d want predictable iteration order (which is insertion order by default), you could easily swap out theHashMapfor aLinkedHashMap. This wouldn’t be as easy if you were usingHashtable.Since synchronization is not an issue for you, I’d recommend
HashMap. If synchronization becomes an issue, you may also look atConcurrentHashMap.