Answer:
This object is reference variable which used to point current object.
This keyword can be used inside method of class.
The this keyword is used inside any method to call another method of same class.
Their are following situation in which we use this keyword
1.For variable hiding we can used the this keyword in java .
2.The this keyword can be used inside constructor to call another constructor of same class
3.The this keyword can be used to return the instance of current class.
Following are the example of this keyword
class Main
{
Main() //Default constructor
{
this("hello"); //it can call another constructor of string parameter
System.out.println("brainly");
}
Main(String str1) // parametrized constructor
{
System.out .println(" String" + str1);
}
public static void main(String[] args) // Main method
{
Main obj = new Main(); // creating object of Main class
}
}
Output:
String hello
brainly
This is an example of this keyword which can be used inside constructor (Main) to call another another constructor(parametrized ) of same class .