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 callUtilization of java this watchword
Here is given the 6 utilization of java this watchword.- this can be utilized to allude current class case variable.
- this can be utilized to conjure current class strategy (certainly)
- this() can be utilized to conjure current class constructor.
- this can be passed as a contention in the strategy call.
- this can be passed as contention in the constructor call.
- 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
0 Comments
Your Comment is Submitted