Friday, April 14, 2017

Using Java Constructors

Here is the code that instantiates an object form the prior EmployeeDetail2 class. It inputs an employee id. If the id is 0 it invokes the no argument constructor, otherwise it inputs the name and salary and invokes the constructor that takes arguments. On another note I forgot to mention that having multiple constructor with the same name is called overloading. We will see this same term later with methods.

 View expanded image on

No comments:

Post a Comment