how fuction the operator this | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

how fuction the operator this

this in Java

22nd Oct 2017, 4:55 PM
Brayan Pérez Ramos
Brayan Pérez Ramos - avatar
2 Answers
22nd Oct 2017, 5:02 PM
Nanda Balakrishnan
0
The "this" operator is a nifty way of objects referring to themselves. In some cases, you will need to reference an object from within its own code, such as if you need to access an instance variable that shares a name with a locale variable. For example: public Something(int temp){ this.temp = temp; } The operator "this" denotes it is referencing an instance variable, and not the parameter "temp". There are other uses, though you won't see them as often.
22nd Oct 2017, 10:07 PM
Quantallax