Unable to apply the constructor in the class to the given type

Project scene:

Error: (13, 29) java: Unable to apply the constructor Customer in the class com.bank.Customer to the given type;
required: no parameters
found: java.lang.String, java.lang.String
reason: actual parameter list Different from the length of the formal parameter list


Problem Description:

Encountered the error during the exercise

    public void Customer(String firstName,String lastName){
    
    
        this.firstName = firstName;
        this.lastName = lastName;
    }

Cause Analysis:

No void can be added in front of the construction method.


solution:

    public Customer(String firstName,String lastName){
    
    
        this.firstName = firstName;
        this.lastName = lastName;
    }

After watching it for a long time, I hope to quit it in the future.

Guess you like

Origin blog.csdn.net/qq_43668890/article/details/114109584