gpt4 book ai didi

java - IntelliJ 2018.1.3 显示接口(interface)中的所有方法,为什么?

转载 作者:行者123 更新时间:2023-11-29 10:09:14 25 4
gpt4 key购买 nike

<分区>

假设我们有以下代码:

public interface Dvd {
void startDvd();
}

和另一个接口(interface):

public interface Tv {
void startTv();
}

和一个类:

public class Logitech implements Dvd, Tv {
@Override
public void startDvd() {

}

@Override
public void startTv() {

}
}

然后当你创建一个实例时:

public class Demo {
public static void main(String[] args) {
Tv tv = new Logitech();
tv. //here when we click the . we expect to see only the startTv()
//method, as the type of our reference is Tv
}
}

但是显示的是:

an image of my intellij code complete

这不是使抽象 OOP 概念无效吗,因为它总是向我展示我的类实现的接口(interface)中的所有方法,有时这可能是大量的方法,对我来说不会隐藏任何复杂性?

为什么我看到这两种方法而不仅仅是 startTv()?

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