0

what is the function of "this" keyword??

1st Nov 2016, 9:27 PM
Uwem Neku
Uwem Neku - avatar
2 Answers
+ 2
class Client(){ private String name; public void setName(String name){ this.name = name; //this.name = class variable //name in method = parameter } }
1st Nov 2016, 10:51 PM
Wanderlei Borges
Wanderlei Borges - avatar
+ 1
What is this? this is a keyword in Java. It can be used inside the Method or constructor of Class. It(this) works as a reference to the current Object whose Method or constructor is being invoked. The this keyword can be used to refer to any member of the current object from within an instance Method or a constructor. http://javabeginnerstutorial.com/core-java-tutorial/this-keyword-in-java/
1st Nov 2016, 10:54 PM
Hasan Al-Yazidi
Hasan Al-Yazidi - avatar