更新时间:2021-12-20 03:35:44
当您在子类中重新定义具有相同签名的方法时,会发生方法覆盖.
Method overriding happens when you redefine a method with the same signature in a sublcass.
所以这里你覆盖了 hashCode()
,而不是 toString()
So here you are overriding hashCode()
, not toString()
@Override
注释是可选的(但这是一件非常好的事情),并表明它应该被覆盖.如果您拼错了某些内容或输入了错误类型的参数,编译器会警告您.
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
)