Alex Rivera | Logout

Call to super must be first statement in the constructor, but it is

Asked 2013-05-06T21:19:12.153
18

I keep getting an error saying that "call to super must be the first statement in the constructor".

The problem is that it is the first statement in my constructor.

public void CheckingAccountCustomer(int a){
    super(n, p, b);
    accountNo = a;
}

And here is my superclass for this as well.

public void customer(String n, int p, double b){
    name = n;
    pin = p;
    balance = b;
}

What am I doing wrong here?

Edit
Report

1 Answer

2

The constructor is used to create an instance of that Class, so it make no sense if it will let the user to change the return type (it can be dangerous too). That's why constructors has no return type.

As others have already answered, remove the return type and it'll become a constructor.

answered 2013-05-06T21:25:32.037

Your Answer