You are on page 1of 1

//Program to demonstrate 'this' keyword

class ThisDemo
{
int x,y;
ThisDemo(int x,int y)
{
this.x=x;
this.y=y;
}

void display()
{
System.out.println("x=" + x);
System.out.println("y=" + y);
}
}

public class Demo3


{
public static void main(String[] args)
{
ThisDemo d = new ThisDemo(1,2);
d.display();
}
}

Output:

x=1
y=2

You might also like