Donnerstag, 11. Dezember 2008

EE3206 java this reference

EE3206/EE5805: Java programming and Applications

notes Liang(2009), p 334

The "this" reference is the name of a reference that refers to a calling object itself.

this.i=i; means "assign the value of parameter i to the data field i of the calling object."

We can also use "this" to invoke another constructor of the same class.

Eg:

public Circle()
{
// invoke another constructor
this(1.0);
}




Keine Kommentare: