This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes equals() method - comparing Objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "equals() method - comparing Objects" Watch "equals() method - comparing Objects" New topic
Author

equals() method - comparing Objects

Kevin Nielsen
Greenhorn

Joined: Jul 27, 2005
Posts: 8
Hi guys,

I'm studying for the SCJP 1.5 exam by reading the K&B book and some additional stuff (Sun's JDK 1.5 tutorials + other things).

I'm a bit confused over a statement in the K&B book - page 389 - "Wrappers won't pass equals() if they're in different classes"

...does this also means (like the == operator), that my own objects will fail the test or does this only apply to Wrappers?

Can somebody help on this?

regards,
Kewin
Joyce Lee
Ranch Hand

Joined: Jul 11, 2003
Posts: 1392
Hi Kewin,

"Wrappers won't pass equals() if they're in different classes"

This statement is explained with a code example on page 384 of K&B.

Here is another example:


Joyce
[ July 27, 2005: Message edited by: Joyce Lee ]
 
GeeCON Prague 2014
 
subject: equals() method - comparing Objects