+ 5
why is Hashtable considered as an obsolete collection
when I tried to use Hashtable in java it says it is a obsolete collection and gives a warning. so can't I use Hashtable? can anyone please tell me the reason it is an obsolete collection
2 Réponses
+ 3
thanks
😀
+ 1
Java now recommends using Map.
Here's a quote from the relevant Java documentation (adding extra whitespace for readability):
As of the Java 2 platform v1.2, this class was retrofitted to implement the Map interface, making it a member of the Java Collections Framework.
Unlike the new collection implementations, Hashtable is synchronized.
If a thread-safe implementation is not needed, it is recommended to use HashMap in place of Hashtable.
If a thread-safe highly-concurrent implementation is desired, then it is recommended to use ConcurrentHashMap in place of Hashtable.