Why do I get a 'constructor is undefined` error?

Jaja

Why would the following code yield a compilation error (The constructor AA() is undefined)? Shouldn't it call a default constructor?

public class A{
    public A(){ }
}

public class AA extends A{
    public AA(int aa){ }
}

public class C{
    public static void main(String[] args){
        A a= new AA();
    }
}
CKing

The compiler will only add a default constructor to a class if there is no constructor in the class which is not the case for AA.

8.8.9 Default Constructors (Java language specification)

If a class contains no constructor declarations, then a default constructor is implicitly declared

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Why do I get a "no matching constructor error?

Why do I get property of undefined error?

Why do I get an error while coding the constructor?

Why am I getting a Constructor Undefined error?

Why I get undefined if value is present in constructor?

Why do I get an undefined constant error in Laravel?

Why do i get the - TypeError: undefined is not a function error?

Why do I get an undefined method error in Ruby on Rails app?

Why do I get an error undefined reference to `getche'?

Why do I get an Undefined reference error when trying to compile?

Why I get this error in flutter? Constructor error?

Why I get NULL is undefined error?

Why i get Undefined error in getgrgid() function

Why do I get property 'map' is undefined

why do i get undefined in the console in JavaScript

Why do I get undefined plus the value?

Why do I get undefined here?

Why do I get undefined variable in an if statement?

Why do i get QJsonValue(undefined)?

Why do I get 'undefined' error when I try to read session atrribute from Controller

Why do I get an error (Notice: Undefined index) when I try to echo a value from my database?

Why do I get this "undefined method" error in a Rails model callback, passing the method as a symbol?

Why do I get a "cannot read property of undefined" error when the data is defined?

Why do I get an undefined variable error when trying to use PHP in two sections of a page?

Why do I get the error message "undefined is not a function" when trying to cancel a promise on press?

Why do I get this error TypeError: Cannot read property 'utf8Slice' of undefined

Why do I get an undefined local variable or method error when using a constant, but not when using a method?

Why do I get "undefined reference"-error with a variable marked as 'extern'? Linker problem?

Why do I get an undefined error when calling a function without parameter?