Two uses of "this" keyword are
1) To resolve the ambiguity between instance variables and parameters.
2) To pass the current object as a parameter to another method.
consider this code:
the code provides a class definition that demonstrates these uses.The MyDate class declares instance variables, (lines 2-4). One of the parameters to one of the constructors(line 6-10) is also called day,so in that context the keyword this resolves the ambiguity(line 7).The addDays method creates a new date object(line 18).IN THIS CONSTRUCTOR CALL,the method uses this keyword as an argument to refer to the current object.
please note the line codes which has a * .I have numbered the code for you for more understanding.
thank you
Ammar Salem
[ January 17, 2008: Message edited by: Ammar Salem ]
[ January 17, 2008: Message edited by: Ammar Salem ]