Friday, April 14, 2017

Java constructor

This is the Java EmployeeDetails class with a constructor, Constructors are used to initialize the instance variables in an object when an object is instantiated form a class. If no arguments are passed in to the constructor then a no args constructor is applied. If the programmer does not supply a no args constructor then Java initializes the instance variables to default settings defined by their data type. You can have multiple constructors with the same name but their signatures must differ in the number of arguments passed.

 View expanded image on
Click on the image for an expanded view on

No comments:

Post a Comment