Hash table

R

Rajesh.Rapaka

Hi,

I am using Hash table for a part of my program. where I am haing index
& values.

Till now I am giving indexes to get values.

but now I want to know what indexes are present in the hash table.

is there a method with which i can get a list of the indexes available
in the hash table.

thanks in advance.
Rajesh Rapaka.
 
B

Bart Cremers

Rajesh.Rapaka schreef:
Hi,

I am using Hash table for a part of my program. where I am haing index
& values.

Till now I am giving indexes to get values.

but now I want to know what indexes are present in the hash table.

is there a method with which i can get a list of the indexes available
in the hash table.

thanks in advance.
Rajesh Rapaka.

Set keySet = Hashtable.keySet();

Regards,

Bart
 
R

Rajesh.Rapaka

Set keySet = Hashtable.keySet();

Regards,

Bart

Hi,

I guess according the algorithm of Hashtable, the key values are
shuffled. is there any possibility to get the keys in the order I
added?

say I added 1,2,3, & 4. But when I ask for key values I get 2,4,3 & 1.
Is there a posssiblity that i can get it as 1,2,3&4.

Thank you,

regards,
Rajesh Rapaka.
 
B

Bart Cremers

Rajesh.Rapaka schreef:
I guess according the algorithm of Hashtable, the key values are
shuffled. is there any possibility to get the keys in the order I
added?

say I added 1,2,3, & 4. But when I ask for key values I get 2,4,3 & 1.
Is there a posssiblity that i can get it as 1,2,3&4.

Thank you,

regards,
Rajesh Rapaka.

Not with a Hashtable. You'll need to use a LinkedHashMap to get that
behavior. Note that LinkedHashMap was only add to Java since v1.4.

Regards,

Bart
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top