Opening Hours :7AM to 9PM
this.variablename
class Demo
{
int x=10; // global variable
void show()
{
int x=20; // local variable
System.out.println(x); //local
System.out.println(this.x); //global
}
}
class Main
{
public static void main(String args[])
{
Demo d=new Demo();
d.show();
}
}
class Demo
{
Demo( )
{
System.out.println("This is NOPC");
}
Demo(int x)
{
System.out.println("This is 1PC");
}
Demo(int x,int y)
{
System.out.println("This is 2PC");
}
}
class Main
{
public static void main(String args[])
{
Demo d1=new Demo();
Demo d2=new Demo(10);
Demo d3=new Demo(10,20);
}
}
class Demo
{
Demo( )
{
this(10);
System.out.println("This is NOPC");
}
Demo(int x)
{
System.out.println("This is 1PC");
}
Demo(int x,int y)
{
this();
System.out.println("This is 2PC");
}
}
class Main
{
public static void main(String args[])
{
Demo d3=new Demo(10,20);
}
}