Solved

hash table to hash map

Posted on 2003-12-11
6
345 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 30 total points
ID: 9925911
Should be hashMap.putAll(hashtable).
0
Independent Software Vendors: 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 20 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

Independent Software Vendors: 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

Suggested Solutions

Title # Comments Views Activity
servlet filter example 37 83
printf performancy 11 86
Is there a simpler dropbox system? 10 44
Notify sent to other threads in Java 9 43
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

749 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