Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How many Object classes overridded the equals() method?

 
Fox Hu
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How many Object classes overridded the equals() method ?
If possible please tell me what are they .
Thank you .
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many. Look out for equals(Object) at http://java.sun.com/j2se/1.4.1/docs/api/index-files/index-5.html
 
Jasper Vader
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there is only one Object class ...
 
Fox Hu
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I mean some of the subclasses of Object .
 
Fox Hu
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A book saied as fallows:
The equals() method is a special method contained in the Object class that compares properties between two objects. The properties that the method tests are determined by the type of object being tested. This is in contrast to the == operator, which tests whether two reference variables are the same, as described earlier in the chapter.

The equals() method is typically overridden in a subclass. When this method is not overridden, it is identical to the == operator (it compares two reference variables). For the Java exam you will need to know the behavior of String, Boolean, and Object types.

I just want to know how many these Subclasses are .
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then you will have to count them. Is there any particular reason you need to know this?
 
Fox Hu
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I am preparing for the SCJP 1.4 exam.
Do I need to know this?
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ths SG:
Well I am preparing for the SCJP 1.4 exam.
Do I need to know this?

No you don't need to know this. You *do* need to know how and where to find out whether or not a class does override the equals() method. And while you're reading the appropriate docs check if that class overrides the hasCode() method also, if not, start revolting and sending in bug reports.
kind regards
ps. My guess is that *nobody* knows from the top of his/her head how many classes override these methods ...
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's good to know for the exam that StringBuffer does not override Object.equals(), but String does.
[ January 28, 2003: Message edited by: Barry Gaunt ]
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would probably be easier to count the classes that DON'T override the equals method. However, such details aren't necessary for the exam. As stated, you need to know when to use the equals() method and how to find out if a class overrides this method.
[ January 28, 2003: Message edited by: Layne Lund ]
 
Fox Hu
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ilja Preuss,your page is great
and thanks everyone,your suggestions are very helpful.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic