Overlapping method signatures in java -


old question:

i've read somewhere implementing 2 interfaces similar method signatures in same class, isn't choice , can lead problems. trivial program underwritten works fine. then, kind of problems? undefined behaviour or it leads design issues? couldn't it. language specifications on helpful.

/* ------------------ */ public interface ia {      public void method(); } public interface ib {      public void method(); } /* ------------------ */ public class c implements ia, ib {      @override     public void method()      {         system.out.println("class implementing 2 interfaces");     }     public static void main(string args[])     {         new c().method();     } } 

edit:

i'm aware of diamond problem , if i'm not wrong java avoids it. point different. edit, i'm rephrasing question as, since, "implementing 2 interfaces similar method signatures" in same class valid in java, why considered bad choice so? perspective of design, , other issues might prevail in such practice.

i think main issue here design issue. same method name has different semantics different interfaces. example, if implement interfaces runnable , player , both have run method, should implementation like? runnable#run generic method run snippet of code, while player#run meant increase players movement speed.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -