1 2 interface Child extends Parent { 3 public interface Inner { 4 public String ok(); 5 } 6 } 7 8 9 interface Parent { 10 public Child.Inner getChildInner(); 11 } 12 13 public class ParentInterfaceUsingChildInnerInterfaceLJH { 14 public static void main (String [] args) { 15 Example me = new Example(); 16 String result = me.getChildInner().ok(); 17 if(!((result != null) && result.startsWith("ok"))) 18 System.out.println("expected ok... got " + result); 19 } 20 } 21 22 class Example implements Parent { 23 public Child.Inner getChildInner() { 24 return new Child.Inner() { 25 public String ok() { 26 return "ok: " + getClass().getName(); 27 } 28 }; 29 } 30 } 31 | Popular Tags |