This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Wrapper class Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Wrapper class" Watch "Wrapper class" New topic
Author

Wrapper class

santhosh.R gowda
Ranch Hand

Joined: Apr 06, 2009
Posts: 296
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]


Creativity is nothing but Breaking Rules
Maverick Uta
Greenhorn

Joined: Apr 29, 2009
Posts: 1
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

Joined: Feb 18, 2008
Posts: 283

Ya its correct


-Chiru
santhosh.R gowda
Ranch Hand

Joined: Apr 06, 2009
Posts: 296
Thanks Jesper Young now i got the point .......
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Wrapper class
 
Similar Threads
KB 235
Strange Behaviour Of Wrapper Class
Strange Behaviour Of Wrapper Class
Difference in results for JDK 1.4 And 1.5
Wrapper comparison.