Code For NonGeek
Would you like to react to this message? Create an account in a few clicks or log in to continue.

What's the difference between a HashTable and a HashMap?

Go down

What's the difference between a HashTable and a HashMap? Empty What's the difference between a HashTable and a HashMap?

Post  Admin Wed Sep 28, 2011 12:01 pm

Hashtable is synchronized, whereas HashMap is not. This makes HashMap better for non-threaded applications, as unsynchronized Objects typically perform better than synchronized ones.

Hashtable does not allow null keys or values. HashMap allows one null key and any number of null values.

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 the HashMap for a LinkedHashMap. This wouldn't be as easy if you were using Hashtable.

Admin
Admin

Posts : 131
Join date : 2011-08-16

https://codefornongeek.forumotion.com

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum