本节课程将学习以下内容:
- protected权限
protected权限
- protected权限首先拥有和default一样的功能;
- 但是它只能修饰成员变量和成员函数;
- 允许跨软件包的继承;
- 只允许类的子类继承使用它的protected成员属性和函数;
例子:(请动手)
1、新建一个Person.java源文件:
1 |
|
2、新建一个Student.java源文件:
1 |
|
权限的总结
- public > protected > default > private
欣慰帮到你 一杯热咖啡

【奋斗的Coder!】企鹅群

【奋斗的Coder】公众号
