• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Wrappers

 
Greenhorn
Posts: 16
Hibernate Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
I remarked that if the value of the Integer Object that was declared as [Integer a=xxxx;] and the value set (xxxx) is in the byte range
the == operator checks values , however if the value is out of that rang the == operator checks references .
Is there any one who can confirm it ? and explaine why .
What about Double/Byte ...
thanks in advance .

 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The == operator compares the values of the references. If they are the same it means both references refer to the same object. == never checks the values of the objects that the references refer to.
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The reason you're getting different results for 127/128 isn't because the == operator behaves differently. == always does exactly the same thing. It's because autoboxing behaves differently.
 
Rachid Aourich
Greenhorn
Posts: 16
Hibernate Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
owkey , thanks ,
what about Double/Byte ... Does the Auto-boxing behaves differently for them :|
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is the equivalent of Double and Byte work similarly. Take a look at the source code for those classes (you can find it in src.zip in the JDK installation directory) and you can answer your own question.
 
Rachid Aourich
Greenhorn
Posts: 16
Hibernate Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you , your response was very helpful
these is the code ..
 
reply
    Bookmark Topic Watch Topic
  • New Topic