Java – type A has defined an error

I tried to search for a solution, but I found that I didn't know how to apply it in this case Please help me correct my code

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");
    }  
}

Solution

Well, the first thing to check is whether there is another class called A. in your file or the same package

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>