public class TestThis
{
	int x = 10;
	static int y = 20;
	final int z = 30;
	void dispvalue()
	{
		int x = 5;
		int y = 10;
		int z = 25;
		System.out.println("Printing Local variables");
		System.out.println(x +" " +y+ "  "+z);
		System.out.println("Printing Instance variables");
		System.out.println(this.x +" " +this.y + " "+this.z);
	}
	public static void main (String args[])
	{
		TestThis temp = new TestThis();
		temp.dispvalue();
		System.out.println("Printing values in main");
		System.out.println(temp.x+ " "+temp.y+" "+temp.z);
	}
}

Click here to go back.

Our aim is to provide information to the knowledge seekers.


comments powered by Disqus

Footer1