Skip to content

Commit 3ee266c

Browse files
committed
java基础:重写与重载
1 parent 58f50b2 commit 3ee266c

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.zz.java.overridetest;
2+
3+
/**
4+
* @Author: zengzhen
5+
* @Date: 2019/7/8 11:06
6+
* @Version 1.0
7+
*/
8+
public class FatherClass extends SunClass{
9+
@Override
10+
public final void sing() {
11+
System.out.println("father - sing");
12+
super.sing();
13+
}
14+
@Override
15+
public final void dance() {
16+
System.out.println("father - dance");
17+
}
18+
19+
public static void main(String[] args) {
20+
FatherClass fatherClass=new FatherClass();
21+
fatherClass.sing();
22+
}
23+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.zz.java.overridetest;
2+
3+
/**
4+
* @Author: zengzhen
5+
* @Date: 2019/7/8 11:05
6+
* @Version 1.0
7+
*/
8+
public class SunClass {
9+
public void sing()
10+
{
11+
System.out.println("sun - sing");
12+
dance();
13+
}
14+
public void dance()
15+
{
16+
System.out.println("sun - dance");
17+
}
18+
}

0 commit comments

Comments
 (0)