Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Maps  RSS feed

 
Sherry Jacob
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I made this simple program for inserting elements in2 a Map and then displaying the elements of the Map :



THe program does not compile...it gives an error :



Why ? The put() method takes two objects as parameters.
I have converted the primitive values to their respective Object types...still the error ??

Please help...
 
Steve McCann
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sherry

You can't cast from a primitive to an Object. Try creating a new Integer rather than casting, e.g.

Steve
[ August 04, 2005: Message edited by: Steve McCann ]
 
Sherry Jacob
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Steve McCann:
Hi Sherry

You can't cast from a primitive to an Object. Try creating a new Integer rather than casting, e.g.

Steve

[ August 04, 2005: Message edited by: Steve McCann ]



eeeeeeh....what's up doc ? Thanx abunch Steve...it worked. I made an elementary mistake !!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!