What is this? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is this?

Not use this keyword but still refer to its object, why? https://code.sololearn.com/cnjfnHoNfNvT/?ref=app

7th Sep 2019, 3:57 PM
Prasetya
Prasetya - avatar
1 Answer
+ 1
Using 'this' is optional. It is still used, so it can "unhide" the properties like this: class Animal { String name; Animal(String name) { // Using "name" would just result in the argument given this.name = name; }
7th Sep 2019, 5:14 PM
Airree
Airree - avatar