Reference inner static class : static Member « Class Definition « Java Tutorial






class MyClassesDemo {
  public static void main(String[] args) {
    MyClass tlc = new MyClass();

    MyClass.NestedMyClass ntlc;
    ntlc = new MyClass.NestedMyClass();
  }
}

class MyClass {
  private int i;
  private static String name = "MyClass";
  {
    System.out.println("Assigning 1 to i");
    i = 1;
  }

  static class NestedMyClass {
    int j;
    {
      System.out.println("Assigning 2 to j");
      j = 2;
      System.out.println(name);
    }
  }
}








5.12.static Member
5.12.1.Static Members
5.12.2.Define the static member
5.12.3.Demonstrate static variables, methods, and blocks.
5.12.4.Inside main( ), the static method callme( ) and the static variable b are accessed outside of their class.
5.12.5.reference static field after declaration
5.12.6.static section of Initializer
5.12.7.static section Initializer and logic
5.12.8.Initializer for final static field
5.12.9.Demonstrates Static nested Classes
5.12.10.Reference inner static class
5.12.11.Static field, constructor and exception