Java : @ Override
The main reason @Override was created was to deal with simple (but nasty) typographical errors. For example, a method mistakenly declared as :
public int hashcode(){
...
}
is in fact not an override - the method name has all lower case letters, so it doesn't exactly match the name of the hashCode() method.
It will however compile perfectly well. Such an error is easy to make, and difficult to catch, which is a dangerous combination. Using the @Override annotation prevents you from making such errors.
http://www.javapractices.com/topic/TopicAction.do?Id=223
No comments:
Post a Comment