gpt4 book ai didi

java - 'super' 和 'this' 之间的区别

转载 作者:行者123 更新时间:2023-12-01 06:56:54 26 4
gpt4 key购买 nike

Possible Duplicate:
this and super in java

我是开发新手。我仍然无法理解 this 和 super 关键字之间的区别。如果有任何答案,将不胜感激。谢谢。

最佳答案

this

Within an instance method or a constructor, this is a reference to the current object — the object whose method or constructor is being called. You can refer to any member of the current object from within an instance method or a constructor by using this.

super

If your method overrides one of its superclass's methods, you can invoke the overridden method through the use of the keyword super. You can also use super to refer to a hidden field (although hiding fields is discouraged).

关于java - 'super' 和 'this' 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10155365/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com