Does @override annotation actually do something or is it used only to tell the programmer not to change the method signature, when they want to override the method of the superclass (and not cause a compile-time error)?
Let's say we create one interface I, a class A, and a class B which extends A and implements I. Class A has a method saySomething(). Interface I has a method writeSomething(). Now, class B has the same 2 methods but does not annotate them with @override. When I did the same thing, there is no compiler error because I didn't change the method signatures. So does that mean the override annotation is just to show the intent and nothing more?
public interface Run {
void startRunning();
}
public class Animal {
public void speak() {
System.out.println("This is from animal");
}
}
public class Dog extends Animal implements Run{
public void speak() {
System.out.println("This is from dog");
}
public static void main(String[] args) {
Animal animal = new Dog();
animal.speak();
}
public void startRunning() {
System.out.println("Start running");
}
}