Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

mapping a int value

 
nicky sajdok
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello jos
I do not understand what you mean could you please descibe in more detail please
thankyou
nicky
 
Veena Rani
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you be so kind and give me some code examples as im stuck with this
thanks
nicky
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic