You must distinguish between this.
and this()
, so to speak:
In most cases, you use this
as a reference to the current object, i.e. the reference to this object is replaced at runtime for this
. For example, if you use this
as a parameter or this.someMember
link.
You can have different constructors with different parameters, i.e. overload constructors. At the beginning of the constructor, you can call another constructor using this(parameter_1, ... parameter_n);
as the first instruction.
A good explanation of both cases can be found in the java tutorial about this keyword .
source share