this keyword


Java “this” variable is a reference variable which refers to the current object.

The uses of this keyword in java are as follows:-

  1. this can be used to refer instance variable of current class.
  2. this can be used to invoke the methods of current class.
  3. this() can be used to invoke constructor of current class.
  4. this can be passed as an argument in the method call as well as in the constructor call.
  5. this can be used to return the instance of current class from the method.