auto commit

This commit is contained in:
CyC2018
2018-05-25 22:11:55 +08:00
parent 515eb99c8c
commit 6dbef5559d
4 changed files with 48 additions and 62 deletions

View File

@ -136,7 +136,7 @@ public class Person {
}
public void work() {
if(18 <= age && age <= 50) {
if (18 <= age && age <= 50) {
System.out.println(name + " is working very hard!");
} else {
System.out.println(name + " can't work any more!");
@ -163,9 +163,9 @@ Animal animal = new Cat();
运行时多态有三个条件:
1. 继承
2. 覆盖
3. 向上转型
- 继承
- 覆盖(重写)
- 向上转型
下面的代码中乐器类Instrument有两个子类Wind 和 Percussion它们都覆盖了父类的 play() 方法,并且在 main() 方法中使用父类 Instrument 来引用 Wind 和 Percussion 对象。在 Instrument 引用调用 play() 方法时,会执行实际引用对象所在类的 play() 方法,而不是 Instrument 类的方法。
@ -236,9 +236,9 @@ public class Music {
和关联关系不同的是依赖关系是在运行过程中起作用的。A 类和 B 类是依赖关系主要有三种形式:
1. A 类是 B 类中的(某中方法的)局部变量;
2. A 类是 B 类方法当中的一个参数;
3. A 类向 B 类发送消息,从而影响 B 类发生变化;
- A 类是 B 类中的(某中方法的)局部变量;
- A 类是 B 类方法当中的一个参数;
- A 类向 B 类发送消息,从而影响 B 类发生变化;
<div align="center"> <img src="../pics//c7d4956c-9988-4a10-a704-28fdae7f3d28.png"/> </div><br>