why for "THIS"??
by barkkathulla[ Edit ] 2012-09-22 13:03:12
IN THE BODY OF A METHOD DEFINITION,YOU MAY WANT TO REFER TO THE CURRENT OBJECT-THE OBJECT THE METHOD WAS CALLED ON-TO REFER TO THAT OBJECT'S INSTANCE VARIABLES OR TO PASS THE CURRENT OBJECT AS AN ARGUMENT TO ANOTHER METHOD.
TO REFER TO THE CURRENT OBJECT IN THESE CASES,YOU CAN USE THE THIS KEYWORD.
THIS REFERS TO THE CURRENT OBJECT,AND YOU CAN USE IT ANYWHERE THAT OBJECT MIGHT APPEAR-IN DOT NOTATION TO REFER TO THE OBJECT'S INSTANCE VARIABLES,AS AN ARGUMENT TO A METHOD,AS THE RETURN VALUE FOR THE CURRENT METHOD AND SO ON.