Home Help Java T this java keyword
Questions:Ask|Latest



this java keyword
Posted on: November 18, 2009
"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;
}
}

Related Tags for this java keyword:


Recommend the tutorial

Ask Questions?    Discuss: this java keyword  

Post your Comment


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