Polymorphie durch Schnittstellen

interface I { String foo (); }

class C implements I { .. String foo () { .. } }
class D implements I { .. String foo () { .. } }

class Top {
  void check (I x) { 
    System.out.println (x.foo ()); 
  }
}
Die Methode check ist polymorph: zur Laufzeit ist das Argument x von irgendeinem Typ, der I implementiert.



Johannes Waldmann 2007-06-21