我的Base类在一个包中
package com.practice.array;
public class Employee {
private int age=1;
protected String name="string";
public String lastname="string1";
String familyName="string2";
}
和其他包中的子类
package com.practice.binarytree;
import com.practice.array.Employee;
public class Demo extends Employee{
public static void main(String[] args) {
Employee emp = new Employee();
System.out.println(emp.name);//getting compile time error here
}
}
这里我收到编译时错误,因为'name'的变化可见性为'protected'但name变量已经声明为'protected'