How to access Static variable of Outer class from Static Inner class in java?

A class with in another class is known as inner class, you cannot declare a class static unless it is an inner class. A static inner class is just like other class variables. You can access it (static inner class) without instantiation


You can access the static variable of an outer class just using the class name. Following Java example demonstrates how to access static variables of a class from a static inner class.

public class Outer {
   static int data = 200;
   static class InnerDemo {
      public void my_method() {
         System.out.println("This is my nested class");
   public static void main(String args[]) {
      Outer.InnerDemo nested = new Outer.InnerDemo();


This is my nested class