Hi guys,
It seems HashTable and HashMap implement the same functionality. Could someone tell me what is the difference between them and which one to choose under various conditions ?
HashMap is the "prefered" class. HashTable is older...
That said, many developers still choose to use HashTable because it is synchronized by default. I personally prefer to take care of my own synchronization code, so this isn't a big deal for me...
You can also use a wrapper from the Collection class to turn a Map into a synchronized map...
If you want your Map type collection to be thread safe, then you need to use Hashtable otherwise use HashMap. HashMap gives better performance than Hashtable because of it's non-synchronized methods.