Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

HashMap or HashTable ?

Posted on 2005-04-22
6
Medium Priority
?
318 Views
Last Modified: 2010-03-31
Hello,

I'm about to develop something, which I originally planned to use a HashTable for, as I need something with it's functionality, and I haven't used HashMap's before.

My question is: In what cases would you choose a HashMap over a HashTable?

Regards;
0
Comment
Question by:InteractiveMind
  • 4
  • 2
6 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 1000 total points
ID: 13846206
HashMap is generally to be preferred at all times, but it's not thread-safe. You can make it thread safe through the collections API if necessary though
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13846211
>> ... at all times  ...

(Apart from when legacy code support is needed)
0
 
LVL 25

Author Comment

by:InteractiveMind
ID: 13846240
Hey CEHJ,

I'm not sure what you mean by "Thread Safe". Could you please elaborate?

Cheers.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Expert Comment

by:CEHJ
ID: 13846262
You need to ensure that the Map's behaviour is predictable when accessed by multiple threads:

http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collections.html#synchronizedMap(java.util.Map)
0
 
LVL 25

Author Comment

by:InteractiveMind
ID: 13846276
Ah, I get it.  :-)

Thanks, once again, CEHJ.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13846286
:-)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month21 days, 3 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question