GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes How many Object classes overridded the equals() method? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How many Object classes overridded the equals() method?" Watch "How many Object classes overridded the equals() method?" New topic
Author

How many Object classes overridded the equals() method?

Fox Hu
Ranch Hand

Joined: Jan 23, 2003
Posts: 49
How many Object classes overridded the equals() method ?
If possible please tell me what are they .
Thank you .
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Many. Look out for equals(Object) at http://java.sun.com/j2se/1.4.1/docs/api/index-files/index-5.html


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Jasper Vader
Ranch Hand

Joined: Jan 10, 2003
Posts: 284
there is only one Object class ...


giddee up
Fox Hu
Ranch Hand

Joined: Jan 23, 2003
Posts: 49
I mean some of the subclasses of Object .
Fox Hu
Ranch Hand

Joined: Jan 23, 2003
Posts: 49
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

Joined: May 05, 2000
Posts: 13974
Then you will have to count them. Is there any particular reason you need to know this?


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Fox Hu
Ranch Hand

Joined: Jan 23, 2003
Posts: 49
Well I am preparing for the SCJP 1.4 exam.
Do I need to know this?
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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

Joined: Aug 03, 2002
Posts: 7729
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 ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
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 ]

Java API Documentation
The Java Tutorial
Fox Hu
Ranch Hand

Joined: Jan 23, 2003
Posts: 49
Thanks Ilja Preuss,your page is great
and thanks everyone,your suggestions are very helpful.
 
GeeCON Prague 2014
 
subject: How many Object classes overridded the equals() method?