How to tell the compiler to access the field of the parent or interface?

class Main { public static void main(String[] args) { System.out.println(B.s1); //ошибка } } interface Int { String s1 = "Int";} class A {static String s1 = "A";} class B extends A implements Int{} 

    2 answers 2

    As for the question, do not specify: the variable declared in the interface cannot be redefined.
    Accordingly: you are trying to access a variable that refers to 2 different objects. Here is a great explanation.

      In both cases, you declare a static variable. Accordingly, use the name of the class / interface in which you declared the variable.

       Int.s1