hello I have this code below which maps out my string keys with string values; once it has maped them out it gets the string keys in the order that they are maped out at. my problem is that i want to map some integers out with them ( int keys[]={0,1,2,3,4,5,6,7,8,9} ) How would i do this? please help me nicky
Anonymous
Ranch Hand
Joined: Nov 22, 2008
Posts: 18944
posted
0
ints are primitives, they can't be stored in hashmaps. Use the Integer wrapper class, and store those wrappers in the hashmap:
kind regards
nicky sajdok
Greenhorn
Joined: Jan 22, 2003
Posts: 14
posted
0
Hello jos I do not understand what you mean could you please descibe in more detail please thankyou nicky
Veena Rani
Ranch Hand
Joined: Mar 09, 2000
Posts: 34
posted
0
You can create another hashtable that will map the values in the int array to either key or value of your original key or value array.For this you have to convert int primitive type to Integer object because in the hashtable you can use only objects as key or value. Then use this hashtable as key or value to construct the final hashtable. Veena
nicky sajdok
Greenhorn
Joined: Jan 22, 2003
Posts: 14
posted
0
Could you be so kind and give me some code examples as im stuck with this thanks nicky