Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-1228542

private access modifier apparently ignored in interfaces

XMLWordPrintable

    • 1.1
    • sparc
    • windows
    • Not verified

      class Intmad implements Foo, Bar {
        public static void main(String[] argv) {
          System.out.println(quux);
        }
      }

      interface Foo {
        private int quux = 3;
        int quax = quux+1;
      }

      interface Bar {
        double quux = 7.3;
      }

      gives this compile-time error:

      Intmad.java:3: Reference to quux is ambiguous. It is defined in interface Bar and interface Foo.
          System.out.println(quux);
                             ^
      1 error

      Apparently declared a field "private" in an interface doesn't cut any ice?
      But then why doesn't the compiler complain about the "private" modifier?
      What are the rules here?

            fyellinsunw Frank Yellin (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: