【@verride】标签

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可以让编译器帮助进行检测。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值