wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Wrapper class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
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: 289

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://aspose.com/file-tools
 
subject: Wrapper class