Skip to main content

Posts

Showing posts with the label step to create java inner classes

Nested Classes sample program

Nested Classes In Java, just like methods, variables of a class too can have another class as its member. Writing a class within another is allowed in Java. The class written within is called the nested class , and the class that holds the inner class is called the outer class . class Outer {  private class Inner  {    void dispaly()    {        System.out.println("this is inner class");       }   }  void call()  {    Inner obj=new Inner();    obj.dispaly();  } } class InnerDemo { public static void main(String s[]) {  Outer ob=new Outer();  ob.call(); } } Example solve watch video for understanding  // inner class By Prakash Sonar class outer {  private class Inner  {    void display()   {      System.out.println...

Labels

Show more