Annotation added in Java 1.5. It can be used only for method declaration to indicate that it is overriding a method of the parent class. Override is possible without the Override annotation. So why should you add the Override annotation? That is this article.
Suppose you have a parent class like this:
Parent.java
public class Parent {
private String something;
protected void setSomething(String something) {
this.something = something;
}
}
I wrote the following code because I needed to inherit from this class and override the setSomething method.
Child.java
public class Child extends Parent {
protected void setSomething(Integer something) {
System.out.println(something);
}
}
I made a mistake in the argument type, but I can't notice the mistake because it compiles normally. I don't think it's true that the release will be released without noticing it as it is, but there is a possibility that you will definitely get hooked on the test as an unexpected bug. And here is the reason for adding the Override annotation. If you add the Override annotation, the IDE will detect it as shown below, so you can notice the mistake and solve the problem in advance (of course, the compiler will also detect compilation with the javac command).
Also, if you are using the IDE, it is possible to issue a warning if there is a method that overrides the method of the parent class even if the Override annotation is not attached depending on the setting. In other words, you can always use the Override annotation to detect unintended overrides.
that's all.