Skip to content

Example Employee Class

Here is the Employee class which is used in many of the examples in this site. Employee class has four properties namely id, name, department and age and has getters and setters methods for these properties. Default constructor has also been overloaded to accept id, name and department properties and second overloaded constructor accepts all four properties of an employee.

Employee class overrides the toString method so when Employee object is printed directly using the System.out.println statement, it produces nice summary.

This class has been referred by many examples for demonstration purpose.

About the author

3 comments

Leave a Reply

Your email address will not be published.