Forums.Sureshkumar.net : A Perfect Place to Share Knowledge         Blogs     Games    Magazines    

"Sharing knowledge does not lessen your store, often it gets you more. Sharing plays a key role in relationships and bonding, happens in small steps and is assisted through community membership."

Go Back   SURESHKUMAR.NET FORUMS > TECHNICAL DISCUSSIONS > JAVA Technologies
Register FAQ Members List Calendar Games Blogs Search Today's Posts Mark Forums Read

   

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
Old 30-01-07, 06:45 PM   #1 (permalink)
Senior Member
 
Join Date: Aug 2006
Age: 28
Posts: 275
Thanks: 0
Thanked 5 Times in 5 Posts
Thanks: 0
Thanked 5 Times in 5 Posts
Rep Power: 5 radhika743 is on a distinguished road
HASH MAP Vs HASH TABLE.

Friends, When to use HASH MAP AND HASH TABLE?Under what circumstances we should use HASH MAP AND HASH TABLE?
radhika743 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 30-01-07, 06:49 PM   #2 (permalink)
Moderator
 
GEEK's Avatar
 
Join Date: Nov 2006
Age: 25
Posts: 227
Thanks: 1
Thanked 12 Times in 9 Posts
Thanks: 1
Thanked 12 Times in 9 Posts
Rep Power: 6 GEEK is on a distinguished road GEEK is on a distinguished road
Re: HASH MAP Vs HASH TABLE.

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 difference 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.
And, a third difference is that HashMap permits null values in it, while Hashtable doesn't.
For new code, I would tend to always use HashMap.
GEEK is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 3 Users Say Thank You to GEEK For This Useful Post:
avadhoot.dharmadhikari (30-01-07), sk_kireeti (30-01-07), t_mohan (30-01-07)
Old 30-01-07, 06:57 PM   #3 (permalink)
Moderator
 
GEEK's Avatar
 
Join Date: Nov 2006
Age: 25
Posts: 227
Thanks: 1
Thanked 12 Times in 9 Posts
Thanks: 1
Thanked 12 Times in 9 Posts
Rep Power: 6 GEEK is on a distinguished road GEEK is on a distinguished road
Re: HASH MAP Vs HASH TABLE.

Here you may get 2 more queries..

What is synchronize in this context and What is fail-safe property?

here you go..

1)Synchronized means only one thread can modify a hash table at one point of time.Basically, it means that any thread before performing an update on a hashtable will have to acquire a lock on the object while others will wait for lock to be released.

2)Fail-safe is relevant from the context of iterators.If an iterator has been created on a collection object and some other thread tries to modify the collection object "structurally",a concurrent modification exception will be thrown.It is possible for other threads though to invoke "set" method since it doesnt modify the collection "structurally".However, if prior to calling "set", the collection has been modified structurally, "IllegalArgumentException" will be thrown.
GEEK is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 2 Users Say Thank You to GEEK For This Useful Post:
avadhoot.dharmadhikari (30-01-07), t_mohan (30-01-07)
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
interview Q&A asked in winrunner Spoorthi Testing Tools & QA 80 22-11-08 11:48 PM
C# - How do you add objects to hash table preethisingh vb / asp.net Interview / Technical Questions 0 25-01-07 08:44 PM
technical info on hard drives-2 abeetha.m OTHERS 0 09-07-06 12:29 PM
JAVA collection naga JAVA Technologies 0 21-02-06 06:01 AM
When do we use HASH TABLE and HASH MAP ? aparna3032 JAVA Technologies 3 14-02-06 10:05 AM


All times are GMT +6.5. The time now is 02:03 PM.





Search Engine Optimization by vBSEO 3.1.0