Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

wrapper class?  RSS feed

 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

why output varies in the above program?
 
Bartender
Posts: 1840
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bairava

Do you have any theories yourself?
What is different between the lines of code that you have that would produce a different result?
What about if you try Integer.valueOf(10) ?
What does the == comparasion do as opposed to the .equals() method?

 
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
… and have you read about the Integer.valueOf() method? Or the Java® Language Specification about boxing?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!