This keyword

Catchphrase THIS is a reference variable in Java that alludes to the present protest. ... It can be utilized to allude occurrence variable of current class. It can be utilized to conjure or start current class constructor. It can be passed as a contention in the strategy call

Utilization of java this watchword 

Here is given the 6 utilization of java this watchword.


  1. this can be utilized to allude current class case variable. 
  2. this can be utilized to conjure current class strategy (certainly) 
  3. this() can be utilized to conjure current class constructor
  4. this can be passed as a contention in the strategy call. 
  5. this can be passed as contention in the constructor call. 
  6. this can be utilized to restore the present class occurrence from the technique.

Example

_________________________________________________________________________________
public class human
{
public int a;
public a()
{
System.out.println("variable is" + this.a);
}
}
_________________________________________________________________________________
in this example this is used to call the variable with exist in the same class. if you want to call the variable or a method form a same class this keywork can be used.

Next Lecture