Tag: java this constructor

this() Java - Calling constructor from constructor of same class

May 5, 2014 · 3 min read
###### We have seen earlier constructor overloading with example. In constructor overloading, multiple constructors exist within the same class. Generally, to call multiple constructors, we create multiple objects; almost one object to call each constructor. Now the question is, Is there anyway to call all the constructors with one object creation? Yes, there is. **The magic word is this() Java**.

Java Constructor

May 7, 2013 · 1 min read
##### Java Constructor, Method and Variable comprises of basic constructs in coding. The importance of Java Constructor is it gives properties to an object at the time of creation itself; else requires many method calls.

Constructors and Constructor overloading

March 31, 2011 · 5 min read
A **constructor** looks more like a method but without return type. Moreover, the name of the constructor and the class name should be the same. The advantage of constructors over methods is that they are **called implicitly** whenever an object is created. In case of methods, they must be called explicitly. To create an object, the constructor must be called. Constructor gives properties to an object at the time of creation itself (else, it takes some method calls with extra code to do the same job). Programmer uses constructor for initializing variables, instantiating objects and setting colors. Constructor is equivalent to [init()](http://way2java.com/applets/life-cycle-of-applet/) method of an [applet](http://way2java.com/applets/applets-vs-applications/).