How to Implement Static Inner Class in Java


In this example we will show you how to implement static inner class in Java.

Source Code

package com.beginner.examples;

class Out {

  static class In {
    int a = 1;
  }
}

public class StaticInnerClass {
  public static void main(String[] args) {
    Out.In in = new Out.In(); // new static inner class
    System.out.println(in.a);
  }
}

Output:

1
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments