多态中的this参数
来源:互联网 发布:艾泽拉斯数据库 人口 编辑:程序博客网 时间:2024/06/10 02:30
类1:
public class Animal {
public void voice(){System.out.println("普通动物叫声");
Doget();
}
public void Doget(){
System.out.println("This是隐式参数");
}
}
class Cat extends Animal{
public void Doget(){
System.out.println("喵喵喵");
}
}
类2:public class Test2 {
public static void main(String[] args) {
Animal c = new Cat();
c.voice();
}
}
这里会调用子类的Doget();方法,因为方法有一个this(隐式参数),指的是当前的对象。
0 0
- 多态中的this参数
- C# 方法中的this参数
- C# 方法中的this参数
- C# 方法中的this参数
- C# 方法中的this参数
- java 多参数与this
- MSDN---扩展方法 (C# 方法中的this参数)
- this参数 扩展参数
- java中的多态、继承、this和super
- 隐藏参数this
- Jquery中的this与$(this)
- Jquery中的this与$(this)
- Jquery中的this与$(this)
- Jquery中的this与$(this)
- JQuery中的this和$(this)
- Jquery中的this与$(this)
- Jquery中的this与$(this)
- Jquery中的this与$(this)
- spring springmvc 将事物管理(@Transactional)分别加在 controller和service层
- C/C++中extern关键字详解与应用
- 位运算
- 关于事务的一些基本概念
- LeetCode(455)Assign Cookies
- 多态中的this参数
- 通过SSH实现 端口映射
- 设置隐藏标题栏
- Ubuntu中的符号
- Java中的接口是什么?
- python
- React Native 之 Natigator与NatigatorIOS使用
- 【BZOJ】2111 [ZJOI2010] Perm 排列计数
- Hibernate与Mybatis对比