File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Wrapper class" Watch "Wrapper class" New topic

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

Joined: Apr 29, 2009
Posts: 1
Explanation by Jesper Young in the below post, should answer your question..
Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 290

Ya its correct

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:
subject: Wrapper class
It's not a secret anymore!