This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes == and != for Wrapper Objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "== and != for Wrapper Objects" Watch "== and != for Wrapper Objects" New topic

== and != for Wrapper Objects

Mohnish Khiani
Ranch Hand

Joined: May 17, 2010
Posts: 65
What and how is this happening?

Output :
Rob Spoor

Joined: Oct 27, 2005
Posts: 19649

Autoboxing uses a cache of values between -128 and 127. If you SearchFirst you will find many threads about the same question.

How To Ask Questions How To Answer Questions
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Such as this one.

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Mohnish Khiani
Ranch Hand

Joined: May 17, 2010
Posts: 65
got it...thank you
I agree. Here's the link:
subject: == and != for Wrapper Objects
Similar Threads
Small doubt in Boxing & == & equals()
Wrappers question
Doubts on == given in B&B
Wrapper ==
Boxing, == and equals