• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Type mismatch:cannot convert from int to Integer.

 
Slaxmi Raj
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

when i run this program , getting the error:type mismatch-can not convert int to Integer.
how i reduce this error, Anyone please tell me.

[Added code tags - see UseCodeTags for details]
 
Marcus Kelvin
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when i run this program , getting the error:type mismatch-can not convert int to Integer.


I don't get any errors for the code in the first post using oracle jdk 7 or icedtea jdk 6. What line is it on?

 
Matthew Brown
Bartender
Posts: 4567
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using earlier than Java 1.5, then you'd expect line 14 to throw an error, because you're assigining an int to an Integer reference. Autoboxing allows that, but autoboxing was introduced in 1.5.

You do realise that if that line works it's a pointless statement, though?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic