Arpit Posted January 26, 2002 Share Posted January 26, 2002 public Point(int x, int y) { this.x = x; this.y = y; } ...that's a constuctor for a structure...what I want to know though is why is 'this' needed in there?...and what does it do?...*took me long enough to get 'this''s uses to call methods and stuff, now this...:ermm: * Link to comment Share on other sites More sharing options...
0 Glowstick Posted January 26, 2002 Share Posted January 26, 2002 this.x refers to the int x in the class not the parameter. You'll need this coz your parameters are also called x and y. Here it's mainly to differ. Coz if you do x = x; y = y; Guess what it means and does. Link to comment Share on other sites More sharing options...
0 Arpit Posted January 26, 2002 Author Share Posted January 26, 2002 Gotcha...thanks! Link to comment Share on other sites More sharing options...
Question
Arpit
public Point(int x, int y)
{
this.x = x;
this.y = y;
}
...that's a constuctor for a structure...what I want to know though is why is 'this' needed in there?...and what does it do?...*took me long enough to get 'this''s uses to call methods and stuff, now this...:ermm: *
Link to comment
Share on other sites
2 answers to this question
Recommended Posts