类型 A 已定义错误

2022-09-03 16:31:44

我试图寻找解决方案,但我发现的我不知道在这种情况下如何应用。请帮我更正我的代码。

package Exercise;

public class Ex11_11 {
public static void main(String[] args) {
    A a = new A(3);
    }
}

class A extends B { // type A is already defined, A has a red underline
    public A (int t) {
    System.out.println("A's constructor is invoked");
    }
}

class B { // type B is already defined, B has a red underline
    public B () {
        System.out.println("B's constructor is invoked");
    }  
}

答案 1

Eclipse有时会感到困惑。如果从菜单中进行选择,则可能会修复这些错误。CleanProject


答案 2

好吧,首先要检查的显然是您的文件或同一包中是否调用了另一个类。A


推荐