USE OF THIS KEYWORD

This section of JAVA contains source codes of many different type of Java Programs to learn the JAVA Basics. These Programs are well formatted and easy to understand.

USE OF THIS KEYWORD

Postby aman_1982_2006 on September 4th, 2008, 5:49 am

Code: Select all
//use of this keyboard
class abc
{
   int a,b;
   abc(int a,int b)
   {
      this.a=a;
      b=b;
   }
   void disp()
   {
      System.out.println(a);//4-this refers to global variable
      System.out.println(b);//0-local var of constructor abc
   }
}
class mn3
{
   public static void main(String args[])
   {
      abc a1=new abc(4,3);
      a1.disp();
   }
}
   
aman_1982_2006
 
Posts: 9
Joined: August 30th, 2008, 6:18 am

Return to Java

Who is online

Users browsing this forum: No registered users and 0 guests