usage of this keyword

this keyword means current object. Below are different usages of this keyword in java.
1. Prefix usages of member variables, when its name is same as parameters.
Eg: this.var1/*data member*/ = var1/*parameter*/;

2. To invoke another constructor of same class, from a constructor. this() should always be first statement, and can only be invoked from constructor.
Eg: this();//invokes A1() constructor

3. this is used as current object, directly in a statement.
Eg: A1 obj = this; //assigning current object

All above this usages are shown in below example.

class A1{
private float var1, var2;

public A1()
System.out.println("A1() invoked");

public A1(float var1,float var2)
this();//invokes A1() constructor
this.var1/*data member*/ = var1/*parameter*/;
this.var2 = var2;
System.out.println("A1(float var1,float var2) invoked");

public void show()
A1 obj = this; //assigning current object to obj
System.out.println(" "+var1+" "+var2);
this.display();//can be invoked as display(); also

private void display()


public class ThisDemo {
public static void main(String[] args) {
A1 obj = new A1(40,60);;


Note that this cannot be assigned to any other object. For example below line of code generates a Compiler error, the reason is this is declared as final, and hence it cannot be changed.

You may also like to read:
Why to have a parameter as final?
Can a constructor be final?
why to use final method?