Solved

hash table to hash map

Posted on 2003-12-11
6
344 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
  • 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Checkbox and ListView in Android Layout 4 65
servlet requestdispatcher include and forward differences 1 30
null output 3 25
Is there a simpler dropbox system? 10 20
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
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…

770 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