EMZETT.
Login

Meaning of this

In short: this refers inside a method or constructor to the current object.

In more detail: You mainly need it when parameters and attributes have the same name.

In Depth

class Point {
    int x;
    Point(int x) { this.x = x; }       // this.x = attribute, x = parameter
    Point copy() { return new Point(this.x); }
}

Other use: this(...) calls another constructor of the class; return this; enables method chaining. There is no this in static methods. See constructors.

See also: static, Constructors, Setter