继承的注意事项
来源:互联网 发布:网络视频存储方案 编辑:程序博客网 时间:2024/06/05 03:23
class Father
{
//私有成员变量不能继承
private int num = 10;
public int num2 = 20;
//私有方法不能继承
private void method(){
System.out.println(num);
System.out.println(num2);
}
public void show(){
System.out.println(num);
System.out.println(num2);
}
}
class Son extends Father
{
public void function(){
System.out.println(num2);
}
}
class jicheng
{
public static void main(String[] args){
Son s = new Son();
s.show();
s.function();
//s.method();//子类不能继承父类的私有成员方法
}
}
{
//私有成员变量不能继承
private int num = 10;
public int num2 = 20;
//私有方法不能继承
private void method(){
System.out.println(num);
System.out.println(num2);
}
public void show(){
System.out.println(num);
System.out.println(num2);
}
}
class Son extends Father
{
public void function(){
System.out.println(num2);
}
}
class jicheng
{
public static void main(String[] args){
Son s = new Son();
s.show();
s.function();
//s.method();//子类不能继承父类的私有成员方法
}
}
0 0
- 继承的相关注意事项
- 继承的注意事项
- 继承的注意事项
- 继承的注意事项
- C++中继承的注意事项
- C#中接口多重继承的注意事项
- C#中接口多重继承的注意事项
- C#中接口多重继承的注意事项
- 使用Castle.ActiveRecord的注意事项三:继承
- C#中接口多重继承的注意事项
- 继承ListActivity的自定义列表注意事项
- 类设计和继承的注意事项
- 继承 (inherit )的使用与注意事项
- 继承中的方法重写的注意事项
- 【OC学习-12】什么是类的继承?为什么要继承?以及继承里面的注意事项
- java中继承注意事项
- Java中继承注意事项
- 使用继承需要注意事项
- Java线程并发控制基础知识
- C++实现遍历指定文件或文件夹
- (五)C++编写动态库,以及如何调用
- java编程学习日志 第一课:小白的奋斗之路
- Android编码规范
- 继承的注意事项
- windows命令行脚本
- poj 1050
- XA事务处理
- C# POST,GET 提交数据
- oracle存储过程创建及调用
- CentOS 7更新源为国内阿里云提供的源
- redis学习系列--1.redis下载安装配置
- iOS 10 相机等崩溃