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:
Kommentar veröffentlichen