6 Replies Latest reply: Jun 16, 2010 11:41 PM by 807580 RSS

    Multiple Inheritance problem persists in Interfaces

    807580
      Hi,
      I tentatively made a program and found that multiple inheritance problem of C++ persists even with interfaces. Although this is definetely a special case but I want to know what is this problem known as( i know that this is perhaps known as diamond problem in C++). And is there a way out of this thing.

      interface one
      {
           int i=10;
      }
      interface two
      {
           int i=20;
      }
      interface z extends one,two
      {
      }
      public class xyz implements z
      {
           public static void main(String [] a)
           {
           System.out.println(i);
           }
      }
      O/P
      D:\Education\Java\JavaStudyRoom\Applets>javac xyz.java
      xyz.java:16: reference to i is ambiguous, both variable i in one and variable i
      in two match
      System.out.println(i);
      *^*
      *1 error*


      Thanks for replying