Java Program For Inner Class

class Outer
{
 int outer_x =100;

 void test()
 {
 Inner inner = new Inner();
 inner.display();
 }

 class Inner
 {
   void display()
  {
  System.out.println("display: outer_x=" + outer_x);
  }

 }
}

class InnerClassDemo
{
  public static void main(String args[])
 {
 Outer outer = new Outer();
 outer.test();
 }
}
Bhanu Namikaze

Bhanu Namikaze is an Ethical Hacker, Security Analyst, Blogger, Web Developer and a Mechanical Engineer. He Enjoys writing articles, Blogging, Debugging Errors and Capture the Flags. Enjoy Learning; There is Nothing Like Absolute Defeat - Try and try until you Succeed.

No comments:

Post a Comment