且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

@Override注释

更新时间:2022-06-27 03:38:01

当你重新定义一个方法,在sublcass相同签名的方法压倒一切的发生。

Method overriding happens when you redefine a method with the same signature in a sublcass.

所以在这里你将覆盖散code(),而不是的toString()

So here you are overriding hashCode(), not toString()

@覆盖注释是可选的(但一个非常好的事情),并表示这是有望被改写。如果你拼错的东西或者有错误类型的参数,编译器会发出警告。

The @Override annotation is optional (but a very good thing) and indicates that this is expected to be overriding. If you misspell something or have a wrongly-typed parameter, the compiler will warn you.

所以,是的,第二个说法是正确的(在这种情况下的超类是的java.lang.Object

So yes, the 2nd statement is true (and the superclass in this case is java.lang.Object)