// File: TestStaticLocal.java (Module 10) // // Author: Rahul Simha // Created: Nov 2, 1998 // // Demonstrates static nested classes. class A { // A static member class. public static class B { int x; // Data. public B (int i) { // Constructor. x = i; } public void print () // A method. { System.out.println ("B: x=" + x); } } } public class TestStaticLocal { public static void main (String[] argv) { // Create an instance of B. A.B b = new A.B (1); b.print(); // Prints "1". // Create another instance of B. A.B b2 = new A.B (2); b2.print(); // Prints "2". } }