标签:style blog class code java c
在不同包,子类继承后可以使用父类的protect权限的属性或方法
父类:
package com.tinyphp; public class Father { protected String name; }
子类:
package com.test; import com.tinyphp.Father; class Child extends Father { void read(){ name="tinyphp"; System.out.println(name); } }
调用:
package com.test; class Test { public static void main(String args[]){ Child c = new Child(); c.read(); } }
java:访问权限-protected实例,布布扣,bubuko.com
标签:style blog class code java c
原文地址:http://www.cnblogs.com/tinyphp/p/3724431.html