aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark ""==" and Number-Wrappers" Watch ""==" and Number-Wrappers" New topic
Author

"==" and Number-Wrappers

Sasha Ruehmkorf
Ranch Hand

Joined: Mar 29, 2007
Posts: 115
I just don't understand what happens here:


I think it's strange, that == is not transitive.

Any idea where I can find an explanation of how the ==-operator is compiled exactly?
I haven't found any language-specification other than the java-api so far.
[ April 20, 2007: Message edited by: Sasha Ruehmkorf ]
sharan vasandani
Ranch Hand

Joined: Feb 22, 2007
Posts: 100
when either of the operands of == when using with Integer object is primitive,then Integer object is autoboxed to its primitive value and then compared.
Sasha Ruehmkorf
Ranch Hand

Joined: Mar 29, 2007
Posts: 115
Just found: "If the operands of an equality operator are both of numeric type, or one is of numeric type and the other is convertible to numeric type, binary numeric promotion is performed on the operands"

Really much to learn for the exam...
Richard Boren
Ranch Hand

Joined: Mar 01, 2001
Posts: 233
Hi Sasha,

Try this link Warpper, Boxing, == Huh??

Richard
Arad Chear
Ranch Hand

Joined: Jan 05, 2007
Posts: 98
hi


i hope its clear now
Sasha Ruehmkorf
Ranch Hand

Joined: Mar 29, 2007
Posts: 115
Thanks for your answers.
Yes, it all cleared up. Don't know why but unboxing never came to my mind, I always thought of the primitive type being boxed and then compared to the Integer...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: "==" and Number-Wrappers