Old Question:
I've read somewhere that implementing two interfaces with similar method signatures in same class, isn't a good choice and can lead to problems. A trivial program like underwritten works fine. Then, what kind of problems? Is it Undefined Behaviour or is it that it leads to design issues? I couldn't get it. Something from the language specifications on this will be 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 two interfaces");
}
public static void main(String args[])
{
new C().method();
}
}
Edit:
I'm aware of the diamond problem and if I'm not wrong then Java avoids it. My point was different. So as an edit, I'm rephrasing my question as, since, "implementing two interfaces with similar method signatures" in same class is perfectly valid in java, then why is it considered to be a bad choice to do so? from the perspective of design, and any other issues that might prevail in such a practice.