package com.mindprod.example;
import static java.lang.System.*;
/**
* How to extend an inner class.
*
* @author Roedy Green, Canadian Mind Products
* @version 1.0 2007-11-21
* @since 2007-11-21
*/
public final class TestExtendingInnerAndNested
{
/**
* main program to allocate an Outer/Inner/Nested class and extended Outer/Inner/Nested class
*
* @param args command line not used.
*/
public static void main( String[] args )
{
Outer o = new Outer();
Outer.Inner i = o.new Inner();
out.println( i.indicator() );// prints 0
Outer.Nested n = new Outer.Nested();
out.println( n.indicator() );// prints 1
OuterE oe = new OuterE();
OuterE.InnerE ie = oe.new InnerE();
out.println( ie.indicator() );// prints 2
OuterE.NestedE ne = new OuterE.NestedE();
out.println( ne.indicator() );// prints 3
}
}
/**
* base Outer class
*/
class Outer
{
/**
* nested static class
*/
static class Nested
{
int indicator()
{
return 1;
}
}
/**
* Inner class
*/
class Inner
{
int indicator()
{
return 0;
}
}
}
/**
* extended Outer class
*/
class OuterE extends Outer
{
/**
* extended nested static class
*/
static class NestedE extends Nested
{
int indicator()
{
return 3;
}
}
/**
* extended Inner class
*/
class InnerE extends Inner
{
int indicator()
{
return 2;
}
}
}