This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Java Language Specification 5.1.7 Boxing Conversion If p is a value of type int, then boxing conversion converts p into a reference ref of class and type Integer, such that ref.intValue() == p
If the value p being boxed is true, false, a byte, a char in the range \u0000 to \u007f, or an int or short number between -128 and 127, then let r1 and r2 be the results of any two boxing conversions of p. It is always the case that r1 == r2..
Try the same example with 127 and 128 [ September 30, 2008: Message edited by: Christophe Verre ]
modify i1 and i2 values to 127 your output will change, because Integer class maintains cache for values in the range of -128 to 127. So when ever you use literal assignment it takes values from cache.
SCJP 1.5 94%.
The greatest glory in living lies not in never falling, but in rising every time we fall.
Joined: Sep 22, 2008
i want to know when != encounters what are the vlaues compared exactly does it take memory reference or somehting else