?
Solved

hash table to hash map

Posted on 2003-12-11
6
Medium Priority
?
347 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
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

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!

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month10 days, 4 hours left to enroll

762 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