• Dear Guest, Please do NOT forget to join our JAVA JOBS (ONLY) FACEBOOK GROUP to be aware of latest JAVA openings, and you may also post any JAVA related queries/jobs.

this keyword

#2
first of all "this" is not a variable, it is is a keyword in JAVA. The "this" keyword is refers to the current object and usually used to access the class members of the current instance. In this way if we have the same name for the instance variable and local variable then we can discriminate by using this keyword. For example this.name=name, here this.name refer to the instance variable name and name refer to the local variable.
 
#3
thank u kavita. I agree with u that 'this' is keyword bcoz JVM declares it.

but why 'this' keyword can only be used in functions , not at class level?
that means JVM declare 'this' in every method.. not at class level??
 
Top