haruki jay wrote:I know this may be a very basic question, but what does overriding a method mean?
There are two words used to describe some methods: "overridden" and "overloaded". These are confused all the time.
An
overridden method has the same signature as one in a parent's class. In your case your class implicitly inherits from the Object class which has already defined an "equals" method. When you call equals() on one of your objects you don't want the method in Object to be called, you want YOUR method to be called. If you hadn't supplied your own equals method then calling equals() would have caused the parent's equals() method to be called.
You should also use the "@Override" annotation. This doesn't affect the compiled code but it tells the compiler that you really mean to override a parent's method and so if you screw up and have the same name but different signatures the compiler will give you an error. Example:
An
overloaded method is a method with the same name and return type but different arguments. Example:
The compiler will complain if two methods have the same name and signature, but if you change the signature it works correctly.