This Keyword Assignment Help

Assignment Help: >> Classes and Objects in Java - This Keyword

The 'this' keyword

Sometimes a method will require referring to the object which invoked it. To permit this, java describes the 'this' keyword. This could be used within any method to refer to the current object. That is always a reference to the object on that the method was invoked. You could use this anywhere a reference to an object of the current class' type is allowing.

To understand it in a better way that what this refers to, consider the following version of box ():

// a redundant use of this.

Box(double w, double h, double d) {

This.width;

This.height;

This.depth;

}

This version of box () operates accurately such like as earlier version.  The use of this is redundant, but perfectly correct. Inside box (), this will always refer to the invoking object. Although it is redundant in this case, this is useful in other context.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd