Search This Blog

Monday, 27 January 2014

using "this" keyword in Java

/* program to illustrate this keyword */

package thiskeyword;
class Parent
{
    int h;
    int n;
    String name;
    public void show(int h,int n,String name)
    {
       this.h=h;
       this.n=n;
       this.name=name;
       System.out.println("Values are : "+h+" "+n+" "+name);
    }
    public static void main(String [] args)
    {
        Parent p=new Parent();
        p.show(2,6,"sanjay");
    }
}

output

No comments:

Popular Posts