Passing custom object into another constructor

325 Views Asked by At

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

1

There are 1 best solutions below

0
Michael S On BEST ANSWER

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