why is Hashtable considered as an obsolete collection | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

13th Nov 2016, 7:38 AM
Sunera Avinash
Sunera Avinash - avatar
2 Answers
+ 3
thanks 😀
16th Nov 2016, 2:07 PM
Sunera Avinash
Sunera Avinash - avatar
+ 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.
16th Nov 2016, 1:58 PM
Cee Gee