62,628
社区成员
发帖
与我相关
我的任务
分享



package basic;
public class Employee{
private String name;
protected String hiredate;
public Employee(String name, String hiredate) {
super();
this.name = name;
this.hiredate = hiredate;
}
public String getHiredate() {
return hiredate;
}
}
package basic;
public class Manager extends Employee{
public Manager(String name, String hiredate) {
super(name, hiredate);
}
public void Method(Employee other){
other.hiredate = "xxxx-xx-xx";
}
}
2、你可以这么理解,发布一个软件,有些作用,如果这个软件的实现是不可见的(private),我要改变,自己修改发布,别人拿去用就行了。如果是protected,别人继承了这个软件,就可以直接修改了,这个软件的作用就不是你能控制的了,你即使更新了新的版本也没用,这样的话,你只能向用的人说,我这个软件更新了,是用来干什么的,你要按照我的要求来用。
3、就是访问控制,让什么类能用什么类不能用。