/**
 * Referencing Outer Class Object and Its Value
 */
public class Outer5 
{	
	private int x = 7;
	
	public static void main(String[] args) 
	{
		Outer5 objOuter5 = new Outer5();
		objOuter5.callInnerClassMethod();
	}
	
	public void callInnerClassMethod()
	{
		Inner5 objInner5 = new Inner5();
		objInner5.InnerClassMethod();
	}
	
	public class Inner5
	{
		private int x = 5;
	
		public void InnerClassMethod()
		{
		 System.out.println(x);
		 System.out.println(Outer5.this.x);
		}
	}
}

Output

5
7

Leave a reply