File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

equals() method - comparing Objects

Kevin Nielsen

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?

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:

[ July 27, 2005: Message edited by: Joyce Lee ]
I agree. Here's the link:
subject: equals() method - comparing Objects
jQuery in Action, 3rd edition