How to display the value of the "name" non-static field from the abstract class Confused("ConfusedValue") ? I tried 3 ways, but all have errors. I can display only the Confuslable's name value("ConfusableValue")
interface Confusable {
String name = "ConfusableValue";
String confuse();
}
abstract class Confused {
String name = "ConfusedValue";
abstract Object confuse();
}
public class Test extends Confused implements Confusable {
public static void main(String[] args) {
Test a = new Test();
// --- OK
System.out.println("Confusable.name: " + Confusable.name);
// --- Errors
System.out.println("name: " + name); // Error : The field name is ambiguous
System.out.println("Confused.name: " + Confused.name); // Error : Cannot make a static reference to the non-static field Confused.name
System.out.println("a.name: " + a.name); // Error : The field a.name is ambiguous
}
}