Can I override the equals() method to take a parameter other than Object?

John Zukowski

If you are trying to override a method with a different argument list, that isn't overriding, but overloading. In order for the method to be properly overridden, and thus called appropriately, the subclass method signature must explicitly match that of the superclass. In the case of equals() that means the return type must be boolean and the argument must be Object.

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact