This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Wrapper class

 
santhosh.R gowda
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends
please tell the the difference between == and equals method in wrapper class... For example Integer i1 = 10;Integer i2 =10:
System.out.println(i1==i2) will evaluates true and i1.equals(i2) will also evaluates true..... but in another example Integer i1 = 1000;Integer i2 =1000:
System.out.println(i1==i2) will evaluates false and i1.equals(i2) will evaluates true. tell me how exactly == and equals work in wrapper class .the == evaluates true upto 127 why is it so....?

[MG Edited to take out the confusing smilies in the subject line]
 
Maverick Uta
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Explanation by Jesper Young in the below post, should answer your question..

http://www.coderanch.com/t/436721/Java-General-beginner/java/operators-with-Wrapper-class
 
Chiranjeevi Kanthraj
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya its correct
 
santhosh.R gowda
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jesper Young now i got the point .......
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic