“This” keyword in java is used to refer current class objects.
There are 6 uses of “this” keyword in java
- Accessing class level variable: mostly used if local and class level variable is same
- Accessing class methods : this is default behavior and can be ignored
- For calling other constructor of same class
- Using ‘this’ keyword as return value : for returning current instance from method
- Passing ‘this’ keyword as argument to method Passing : for passing current class instance as argument
- this keyword as argument to constructor : for passing current class instance as argument
ref: https://stacktraceguru.com/java/this-keyword-in-java