Is it just me, or is Java's Override annotation actually useless when programming in a decent IDE?
Yes, I understand that the Override annotation prevents me from accidentally not overriding a super method by misspelling the method name or messing up the method parameters. However, common sense tells me this is very unlikely to happen in modern IDEs, for the following reasons:
Sure, if you have to write your Java code in Notepad or whatever, the Override annotation obviously helps. But my point is, in a modern IDE, the increase in safety provided by this annotation is not worth the decrease in readability. Any opinions?
@Override @Override annotation informs the compiler that the element is meant to override an element declared in a superclass. Overriding methods will be discussed in Interfaces and Inheritance. While it is not required to use this annotation when overriding a method, it helps to prevent errors.
It will throw a compilation error if you have the annotation on a method you're not actually overriding the superclass method. The most common case where this is useful is when you are changing a method in the base class to have a different parameter list.
So really, it's not optional, it's not there at all from the language perspective. Some people do want the feature, even if the language doesn't have it, and they added the @override annotation and analyzer support.
@Override annotation is used when we override a method in sub class. Generally novice developers overlook this feature as it is not mandatory to use this annotation while overriding the method.
Well you have to trust yourself to see those markers. There is a human element to it and humans are fallible. From personal experience I often tend to overlook those warnings and 'markers'. On the other hand, the compiler is far more exacting and if you annotate a method with Override it will make sure that you are really overriding a superclass method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With