0

I have a custom Class Employee. Now in the Customer Class in the first construcor I want to pass a dummy employee object for the second constructor. How can I do this?

Customer Class excerpt

2
  • 1
    You have to import Employee or else it will be undefined. w3schools.com/java/ref_keyword_import.asp Commented Jan 13, 2022 at 18:29
  • Even importing the class or adding it to a package doesn't work. Commented Jan 13, 2022 at 18:43

1 Answer 1

1

Please ask yourself, "is a design I really want?"

You can pass it null or a dummy Employee.

static final Employee DUMMY_VALUE = new Employee();

public Customer(String name, int age){
    this(name, age, "", DUMMY_VALUE);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.