+ 7
What is the use of this keyword ?
5 Respostas
+ 25
this keyword is used to refer the current object
//I saw its use in getter , setter & constructors to initialize the object or take out values of instance members of that object
https://www.javatpoint.com/this-keyword
+ 3
to specify the CURRENT CLASS variable
this.apple
nothing else (kinda, most of the time)
+ 2
In Android it is used to refer to your actual activity/fragment without the need to write it out.
0
Think about it like this. Let’s say that YOU, as a person, are a member of the Person class. You would refer to yourself as “me”, right? And that expresses that you are referring to your own person, not some other person, or persons in general. That’s what “this” is. It is a specific instance of a class referring to itself. (In VB, the functional sister-language of C#, the keyword “me” is used instead of “this”.)