Constructor Overloading In Java Example


Example 1: default constructor java


Default constructor is a constructor created by compiler; if user does not 
create a constructor in a class.
If
user defines a constructor in a class then java compiler will not create
default constructor.

Example 2: Can we overload the constructors


Yes, the constructors can be overloaded by changing the number of 
arguments accepted by the constructor or by changing the data type of
the parameters

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable