The memory for the object is allocated until any constructor is executed. Otherwise, the constructor would not have to write the values of the variables.
Therefore, you can pass a link to the current object (aka this ) to other code fragments inside the constructor.
As you noted, the object was not yet completely constructed at that time, and it is a bad idea to actually do it, but "simply" because the values of the object may be in an inconsistent state. A memory has already been allocated and reserved for this object at a given moment in time.
this is just a reference to the "current object", which you can imagine as just another parameter that any non-static method receives. In fact, this is actually how the JVM treats it. See JVMS §2.6.1 Local variables :
When a method method is called, the local variable 0 is always used to pass a reference to the object to which the instance method is called ( this in the Java programming language).
Thus, the direct response to “when this highlighted” is effective: whenever you call a method on an object.
source share