The class overrides equals(Object o) in java.lang.Object to compare the instance values of two Pixel objects and return true if they are equal, and false otherwise.
Matthew Brown wrote:You're still overloading rather than overriding, though. Try adding an @Override annotation and that will become clear. The signature needs to be equals(Object), not equals(Pixel). You should be able to compare a Pixel to any object (returning false if it isn't a Pixel). It also needs to cope with being compared to null (again, returning false).
I am very well, thank you. So are the rest of the family.Sarah Mitchell wrote:Hello CR,
How is everybody today ? . . .
So, now when I changed the argument to (Object o) I got an error for all the instances I have (x, y and myColor) !!!
How can I resolve this ??
I don't know how to use the @Override thingy
Sarah Mitchell wrote:Uffff, this toke a lot of my time, although your inputs were crystal clear but I just couldn't see it at that time =(
...
Thank you guys, I'm really glad that all of you were nice enough to help me out. Appreciated =)
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Campbell Ritchie wrote:That equals() method will work reliably as long as you cannot make subclasses of Pixel.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Consider Paul's rocket mass heater. |