This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

equals() method - comparing Objects

 
Kevin Nielsen
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic