+ 3
Is is necessary to mention "this" keyword for referring current object?
Any alternative for using 'this' keyword
3 odpowiedzi
+ 5
No alternative. Why would you need one?
Think of "this" as an implicit first parameter of any non-static method of your class.
You can omit the "this." prefixing for attributes of the class inside a method of the class, providing that there are no parameter or variable of the same name in that method. I would suggest to always write it regardless so that readers of your code (including you) immediately understand that you are manipulating an attribute of the class, and not just a variable.
+ 2
you should only really use "this" if you are overloading a variable. otherwise it is basically redundant.
- 1
No