This keyword is used for referring to the current object inside a method or a constructor
A common usage of this keyword in java eliminates the confusion between the parameters and the class attributes using the same name. However, the keyword also has some other critical usages, including:
In java language, this() refers to the constructor, and this refers to the current object of the current class. Thus, this keyword only works with objects, whereas this() call is used to call more than one constructor from the same class.
In java, both super() and this() are the keywords. In programming, super() is used to represent the parent class’s constructor, whereas this() is used to represent the current object’s constructor using the matching parameters.
: Value of x = Knowledge2life
|