?
Solved

Dump all the key from Hashmap to a vector

Posted on 2006-04-18
5
Medium Priority
?
381 Views
Last Modified: 2008-03-17
I wish to dump all the keys from Hashmap to a vector, how to do it?(The concern here is the performance, I wish to use the minimal resources to do this, however, any suggestion is welcome)
0
Comment
Question by:william007
5 Comments
 
LVL 92

Accepted Solution

by:
objects earned 1200 total points
ID: 16475913
Vector v = new Vector(map.keySet());
0
 
LVL 14

Expert Comment

by:StillUnAware
ID: 16475930
I guess the best way would be to use the functions API provides:

Vector v = new Vector();
v.addAll(hashMap.keySet());
0
 
LVL 1

Assisted Solution

by:sriki77
sriki77 earned 400 total points
ID: 16476159
why do you need vector, use the set itself. You have all the power of the collections api on the Set too.
0
 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 400 total points
ID: 16476557
>> The concern here is the performance

BTW, I doubt if Vector will give you better performance than the set itself.
0
 
LVL 9

Author Comment

by:william007
ID: 16478720
Thanks:-)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

In this post we will learn different types of Android Layout and some basics of an Android App.
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 learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses
Course of the Month17 days, 10 hours left to enroll

830 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