Anonymous Local Inner Class Demo

Download Nested.java

/* Simple demo of an anonymous local inner class.
 *
 * 2007 by Wayne Pollock, Tampa Florida USA.
 */

class Base
{
    public void hello ()
    {
        System.out.println( "Hello from Base" );
    }
}

public class Nested
{
   public static void main ( String [] args )
   {
       Base b = new Base() {
          public void hello ()
          {
            System.out.println( "Hello from Anonymous" );
          }
       };

       b.hello();
   }
}