File tree Expand file tree Collapse file tree 7 files changed +98
-16
lines changed
src/main/java/com/cpucode/java
test/src/main/java/com/cpucode/java/test/overrideTest Expand file tree Collapse file tree 7 files changed +98
-16
lines changed Original file line number Diff line number Diff line change 6464- [x] [ polymorphic4__ 多态转型异常] ( src/main/java/com/cpucode/java/polymorphic/polymorphic4.java )
6565- [x] [ polymorphic5__ 多态转型异常判断] ( src/main/java/com/cpucode/java/polymorphic/polymorphic5.java )
6666- [x] [ polymorphic6__ 接口多态的综合案例] ( src/main/java/com/cpucode/java/polymorphic/polymorphic6 )
67+ - [x] [ 多态的覆盖方法] ( src/main/java/com/cpucode/java/polymorphic/OverrideTest.java )
68+
6769
6870- [ 返回object] ( #面对对象 )
6971
Original file line number Diff line number Diff line change 11<?xml version =" 1.0" encoding =" UTF-8" ?>
22<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule=" true" type =" JAVA_MODULE" version =" 4" >
3- <component name =" NewModuleRootManager" LANGUAGE_LEVEL =" JDK_1_5 " >
3+ <component name =" NewModuleRootManager" LANGUAGE_LEVEL =" JDK_1_8 " >
44 <output url =" file://$MODULE_DIR$/target/classes" />
55 <output-test url =" file://$MODULE_DIR$/target/test-classes" />
66 <content url =" file://$MODULE_DIR$" >
Original file line number Diff line number Diff line change 88 <artifactId >objectTest</artifactId >
99 <version >1.0-SNAPSHOT</version >
1010
11+ <build >
12+ <plugins >
13+ <!-- java编译插件 -->
14+ <plugin >
15+ <groupId >org.apache.maven.plugins</groupId >
16+ <artifactId >maven-compiler-plugin</artifactId >
17+ <version >3.2</version >
18+ <configuration >
19+ <source >1.8</source >
20+ <target >1.8</target >
21+ <encoding >UTF-8</encoding >
22+ </configuration >
23+ </plugin >
24+ </plugins >
25+ </build >
1126
1227</project >
Original file line number Diff line number Diff line change 1- /*
2- * @由于个人水平有限, 难免有些错误, 还请指点:
3- * @Author: cpu_code
4- * @Date: 2020-09-13 16:47:12
5- * @LastEditTime: 2020-09-13 17:37:44
6- * @FilePath: \java\object\Abstract\abstract2\Main.java
7- * @Gitee: [https://gitee.com/cpu_code](https://gitee.com/cpu_code)
8- * @Github: [https://github.com/CPU-Code](https://github.com/CPU-Code)
9- * @CSDN: [https://blog.csdn.net/qq_44226094](https://blog.csdn.net/qq_44226094)
10- * @Gitbook: [https://923992029.gitbook.io/cpucode/](https://923992029.gitbook.io/cpucode/)
11- */
121package com .cpucode .java .Abstract .abstract2 ;
132
14- import object .Abstract .abstract2 .Member ;
15- import object .Abstract .abstract2 .QunZhu ;
16-
173import java .util .Scanner ;
184import java .util .ArrayList ;
195
Original file line number Diff line number Diff line change 1+ package com .cpucode .java .polymorphic ;
2+
3+ /**
4+ * @author : cpucode
5+ * @date : 2021/12/21 15:46
6+ * @github : https://github.com/CPU-Code
7+ * @csdn : https://blog.csdn.net/qq_44226094
8+ */
9+ public class OverrideTest {
10+ public static void main (String [] args ) {
11+ Base b = new Derived ();
12+ b .f ();
13+ b .g ();
14+ }
15+ }
16+
17+ class Base {
18+ public Base () {
19+ g ();
20+ }
21+
22+ public void f () {
23+ System .out .println ("Base f" );
24+ }
25+
26+ public void g () {
27+ System .out .println ("Base g" );
28+ }
29+ }
30+
31+ class Derived extends Base {
32+ public void f () {
33+ System .out .println ("Derived f()" );
34+ }
35+
36+ public void g () {
37+ System .out .println ("Derived g()" );
38+ }
39+ }
Original file line number Diff line number Diff line change 1+ package com .cpucode .java .test .overrideTest ;
2+
3+ /**
4+ * @author : cpucode
5+ * @date : 2021/12/21 15:33
6+ * @github : https://github.com/CPU-Code
7+ * @csdn : https://blog.csdn.net/qq_44226094
8+ */
9+ public class OverrideTest {
10+ public static void main (String [] args ) {
11+ Base b = new Derived ();
12+ b .f ();
13+ b .g ();
14+ }
15+ }
16+
17+
18+ class Base {
19+ public Base () {
20+ g ();
21+ }
22+
23+ public void f () {
24+ System .out .println ("Base f" );
25+ }
26+
27+ public void g () {
28+ System .out .println ("Base g" );
29+ }
30+ }
31+
32+ class Derived extends Base {
33+ public void f () {
34+ System .out .println ("Derived f()" );
35+ }
36+
37+ public void g () {
38+ System .out .println ("Derived g()" );
39+ }
40+ }
You can’t perform that action at this time.
0 commit comments