HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
Java Keywords : Using this with a class attribute (x)
The this
keyword refers to the current object in a method or constructor.
The most common use of the this
keyword is to eliminate
the confusion between class attributes and parameters with the same name (because a class attribute is shadowed by a method or constructor parameter). If you omit the keyword in the example above, the output would be "0" instead of "5".
this
can also be used to:
Read more about objects in our Java Classes/Objects Tutorial.
Read more about constructors in our Java Constructors Tutorial.
Read more about methods in our Java Methods Tutorial.