Posted by : Unknown
Sunday, 5 July 2015
class Outer
{
int outer_x = 100;
void test()
void test()
{
Inner inner = new Inner();
inner.display();
}
Inner inner = new Inner();
inner.display();
}
// this is an inner class
class Inner
class Inner
{
void display()
void display()
{
System.out.println("Display: outer_x = " + outer_x);
}
}
}
System.out.println("Display: outer_x = " + outer_x);
}
}
}
class InnerClassDemo
{
public static void main(String args[])
public static void main(String args[])
{
Outer outer = new Outer();
outer.test();
}
}
Outer outer = new Outer();
outer.test();
}
}
Output:
Display: outer_x = 100