Share on Google+Share on Google+

this java keyword

"this" is a keyword defined in the java programming language.

this java keyword


"this" is a keyword defined in the java programming language. Keywords are basically reserved words which have specific meaning relevant to a compiler in java programming language likewise the this keyword indicates the following :

-- The this keyword always refer to the current instance.
-- The this keyword helps in removing the ambiguity of references and allows to refer to the current instance within the running program.
--  key word this is used with variables as "this.variable" and specifies the number of member variable of this instance of that class.

In the example given below, the numbers of arguments in a constructor has the same name as a member variable of a class has.

Example to use the this keyword with a varaible:

public class Class2{

int number;
public Class2(int number){
this.number = number;



Posted on: November 18, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Discuss: this java keyword  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image