类型A已定义错误

Sus*_*usu 11 java eclipse

我试图寻找解决方案,但我发现我不知道如何申请这种情况.请帮我纠正我的代码.

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");
    }  
}
Run Code Online (Sandbox Code Playgroud)

Rob*_*een 30

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


Cra*_*igy 7

好吧,首先要检查的是你是否A在你的文件或同一个包中调用了另一个类.

  • 在eclipse中,我们可以在一个项目中有多个源文件夹,如果文件具有相同的路径结构和名称等,则会发生冲突! (2认同)