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?
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?
- relates to
-
JDK-1234802 fp.bugs 3210 compiler sets methods to public access in interfaces.
- Closed