interface A {
public static String name = "A";
}
interface B {
public static String name = "B";
}
class X implements A { }
class Y extends X implements B { }
public void test_getField() {
try {
assertEquals(B.class.getField("name"), Y.class.getField("name"));
} catch (NoSuchFieldException e) {
fail("Got exception");
}
}
Why does Y.class.getField("name")
return B.name
instead of A.name
? Is there any answer in the Java specification?
Aucun commentaire:
Enregistrer un commentaire