HashMap vs Hashtable
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   elango_maragtham
Posted On:   Tuesday, May 29, 2001 01:58 AM

			
what is the difference between
HashMap vs Hashtable Which is best to Use

Re: HashMap vs Hashtable

Posted By:   John_Zukowski  
Posted On:   Tuesday, May 29, 2001 10:13 AM

Both provide key-value access to data.
The Hashtable is one of the original collection classes in Java. HashMap is part of the new Collections Framework, added with Java 2, v1.2.


The key differnce between the two is that access to the Hashtable is synchronized on the table while access to the HashMap isn't. You can add it, but it isn't there by default.


Another difference is that iterator in the HashMap is fail-safe while the enumerator for the Hashtable isn't. If you change the map while iterating, you'll know.

Re: HashMap vs Hashtable

Posted By:   AlessandroA_Garbagnati  
Posted On:   Tuesday, May 29, 2001 02:13 AM

Hi,

They are almost the same thing. The big differences are that HashMap is the implementation of a Hashtable on a Map interface, is not synchronized, and it allows null values for key and value, while Hashtable doesn't.
About | Sitemap | Contact