Differences between hashmap and hashtable in Java learning)
Source: Internet
Author: User
Hashmap is HashtableLightweight implementation (non-thread-safe implementation), they have completed MapInterface, the main difference is that HashmapAllow null ( Null) Key value ( Key) ,Because of non-thread security, the efficiency may be higher Hashtable.
HashmapAllow NullAs EntryOf KeyOr Value, And HashtableNot allowed.
HashmapSet HashtableOf ContainsThe method is removed and changed ContainsvalueAnd Containskey. Because ContainsMethods are easy to misunderstand.
HashtableInherited from DictionaryClass, while HashmapYes Java1.2Imported Map Interface. The biggest difference is that, HashtableThe method is SynchronizeAnd HashmapNo, access in multiple threads HashtableYou do not need to implement synchronization for its own method. HashmapYou must provide external synchronization for it.
HashtableAnd HashmapUsed Hash/rehashAlgorithmSo the performance will not be significantly different.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service