posted 16 years ago
Every object inherits the equals() method from the Object class. You can then override it to carry out whichever equality tests are required for the class.
What this means is that you must use the same method signature as the Object class. This isn't a problem as every class extends from the Object class therefore every object IS-A Object. Even though the variable o is declared as being of type Object it is still a Moof object. However, in order to access any Moof members you need to first cast it to a Moof object.
Before you try treating o as a Moof object you must first check that it is indeed a Moof object. If it was for example a Dog object and you try accessing a Moof method you would get a ClassCastException.