public class A { private int x; // instance variable of A private static int z = 10; // static variable in A public A() // A's constructor { x= 10; B.showStatic(); B b = new B(); // build object of type B b.show(); // call B's show function } public void show() // instance method of A { System.out.println("x = " + x); System.out.println("z = " + z); System.out.println(); } /* THIS IS A STATIC NESTED CLASS */ public static class B // nested class (static) { private int y; // instance variable of B private static int s = 15; public B() // constructor for B { y = 20; z = 5; // has access to static // variable of class A x = 10; // this would be ILLEGAL, because x is an // instance variable of class A } public void show() { System.out.println("y = " + y); System.out.println("z = " + z); } public static void showStatic() { System.out.println("s = " + s); } } // end of nested class }