Local database reading edition

HashMap is better than Hashtable- Can you guess?

Reconstructed from database records, not a captured original forum layout. Dates and display names are retained as recorded; timezone and real-world identity are not inferred. Historical advice, contact details and offers are not current. Original markup is shown as inert text.

Forum index · Java - Tips Of The Day

Opening post

Asha · 2001-02-13 13:21:42

In this tip, I will give you some ideas on the collections specifically hashtable and hashmap. There are a few differences between hashtable and hashmap. Probably the most important one to you is that Hashtable is fully synchronized while HashMap is not. This means that HashMap is faster, though not thread safe in of itself. (There are ways to make it thread safe.) But also very important is that HashMap implements the Map interface. This allows you to easily substitute OTHER Map implementations in your code. Sometimes a hash isn't the most appropriate algorithm and you might get better performance out of a different Map implementation, such as a Tree. In my work environment we are making a rule &#8220;use hashmap&#8221; <img src=icon_smile.gif border=0 align=middle> and experimented the performance and really it worked faster than hashtable. Go hashmap! Now let us thing of when to use hashtable, I can guess two things, when you are in multithreaded environment(where your object is accessed by more than one thread not each thread has its own objects <img src=icon_smile_blush.gif border=0 align=middle>)then go for hashtable or else hashmap is good .The second would be when you circle around with different Maps then go for hashmap. Asha Balasubramanyan http://www.ammu.org

Source notes

MyCommunity/nandighosha.org.zip!/forum/tools/snitz_forums_2000.mdb
Table: FORUM_TOPICS + FORUM_REPLY · record IDs: 20