Write a program in java to demonstrate 1st use of “this” keyword?

class This

{

                int a,b;

                public This(int a,int b)

                {

                                this.a=a;

                                this.b=b;

                }

                public void display()

                {

                                System.out.println(a);

                                System.out.println(b);

                }

                public static void main(String arg[])

                {

                                This x=new This(7,9);

                                x.display();

                }

}

this Keyword.PNG

, , , , , ,

Leave a Reply