当我将此代码更改为Member m1 = new Member ();
它时,它可以完美运行。为什么它不适用于超级类参考?请问有人可以解释吗?
public class Family {
String Surname = "Richard";
String Address = "No:10, High Street,Colombo";
}
public class Member extends Family{
String Name;
int age;
public void Details() {
System.out.println("full Name ="+ Name +" "+ Surname);
System.out.println("Age =" +age);
System.out.println("Address =" + Address);
}
public static void main(String[] args) {
Member m1 = new Family ();
m1.Name="Anne";
m1.age=24;
m1.Details();
}