Indicates that a method declaration is intended to override a method declaration in a supertype. If a method is annotated with this annotation type compilers are required to generate an error message unless at least one of the following conditions hold:
·The method does override or implement a method declared in a supertype.
·The method has a signature that is override-equivalent to that of any public method declared in Object.
Since:
1.5
来自 https://docs.oracle.com/javase/7/docs/api/java/lang/Override.html
指示一个方法声明,意图重写一个在父类中声明的方法。如果一个方法用这个标签标记,那么只有当以下情况出现时才不会出现编译错误:
·这个方法没有重写或者实现一个在父类中声明的方法
·这个方法有一个标记,等价于重写了在Object类中定义的任何公共方法。
也就是说不写也没事,是为了防止在编程中,override父类方法时写错方法名而没有发现。加上@Override可以让编译器帮助进行检测。