, , , .
:
public class AAA{
public static String HELLO = "HI";
}
public class BBB extends AAA{
public static String HELLO = "Hello World";
}
AAA test = new BBB();
System.out.println(test.HELLO);
static "Hello World".
To prevent these errors, you should always refer to the static variables in the class in which they are declared, instead of using an instance. The compiler warns you because there is no reason not to use the class name.
source
share