Friday, 11 May 2012

Nested Interfaces in Java

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author bjr
*/
public class Main implements nested
{
public static void main(String args[])
{
ImplTopIfImplTopIf m=new ImplTopIfImplTopIf ();
System.out.println("Hello world");
System.out.println(m.fNestedIf1());
}
public static class ImplTopIfImplTopIf implements NestedIf1
{
@Override
public String fNestedIf1()
{
return "NestedIf1 implementation";
}
}

public static class NestedImplNestedIf2 implements NestedIf1.NestedIf2
{
@Override
public String fNestedIf2()
{
return "NestedIf2 implementation";
}
}

public interface NestedIf3
{
String fNestedIf3();
}

public static class NestedImplNestedIf3 implements NestedIf3
{
@Override
public String fNestedIf3()
{
return "NestedIf3 implementation";
}
}

@Override
public String fTopIf()
{
return "fTopIf implementation";
}
}
class ImplNestedIf3 implements Main.NestedIf3
{
@Override
public String fNestedIf3()
{
return "NestedIf3 implementation";
}
}