• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Matching two map values : An exception occured trying to convert String "A" to type "java.lang.Long"

 
Romeo Ranjan
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,

Below is the code that I am working on. I want to loop through the values of the hashmap "a" . If the value of map "a" matches the value of map "a1". I want to print the corresponding key "hello" in hashmap a1.



But this is the error that I get



What do I do in order to rectify the exception. And how do I get the "hello" displayed in the jsp page?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd assume there's some type coercion going on here, thus the error.
 
Bhoomika Bathla
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.....

I run your code in eclipse......it does not show any exception.
 
anbuselvan angamuthu
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i guess you put integer value "new Integer(3)" in a1 map.so you put "new Integer(3)" instant of "new String(3)"
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic