What is the use of this ?

What is the use of this ?

this keyword is used to point to the currently executing object. 

The most common reason for using the this keyword is because a field is shadowed by a method or constructor parameter.

 Example:public class PointExample { public int x = 0; public int y = 0; //constructor public Point(int x, int y) {this.x = x;this.y = y; }}


By:Jalees
Date:2012-01-09 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related Java Subjective Links

Java Subjective interview questions and answers for experienced and fresher