gpt4 book ai didi

java - 覆盖逻辑:Beginner

转载 作者:行者123 更新时间:2023-12-01 16:34:44 25 4
gpt4 key购买 nike

我对覆盖有疑问。

class base{
public void amethod(){}
}
class child extends base{
public void amethod(int i){}}

在这种情况下会发生什么?这些方法被认为是 2 个不同的方法吗?或者它仍然覆盖吗?请澄清。

最佳答案

这不是最重要的,但是 overloading ,并且这两者彼此不相关。

看看Java tutorial :

Overloaded methods are differentiated by the number and the type of the arguments passed into the method. In the code sample, draw(String s) and draw(int i) are distinct and unique methods because they require different argument types.

关于java - 覆盖逻辑:Beginner,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10475708/

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