Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

hash table to hash map

Posted on 2003-12-11
6
Medium Priority
?
348 Views
Last Modified: 2010-03-31
How to convert
java.util.HashTable to java.util.HashMap

eg
I have
HashMap hashMap = new HashMap();
Hashtable hashtable = new Hashtable();

hashMap = hashTable????
0
Comment
Question by:applekanna
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 92

Expert Comment

by:objects
ID: 9925887
hashMap = new HashMap(hashtable);
0
 
LVL 3

Author Comment

by:applekanna
ID: 9925903
hashMap.putValues(hashTable)  is this correct ....
0
 
LVL 92

Accepted Solution

by:
objects earned 120 total points
ID: 9925911
Should be hashMap.putAll(hashtable).
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 4

Assisted Solution

by:tapasvi
tapasvi earned 80 total points
ID: 9925939
objects is right.
but one note here..you may need to synchronize hashmap externally if your application need threadsafety. (of course, in that case u wouldnt have dumped hashtable in first place...but some ppl dont use hashtable at all ..as they believe its not "true" collection..
anyways choice is yours)
0
 
LVL 3

Author Comment

by:applekanna
ID: 9925953
Thx for ur help :)
0
 
LVL 92

Expert Comment

by:objects
ID: 9925975
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

598 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