Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

完成多态方法选择 #128

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/java/com/github/hcsp/polymorphism/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ public class Main {
// "I am Sub, the param is ParamSub"
public static void main(String[] args) {
Base object = new Sub();
ParamBase param = new ParamSub();
ParamSub param = new ParamSub();
object.print(param);

}
}
1 change: 1 addition & 0 deletions src/main/java/com/github/hcsp/polymorphism/Sub.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ public void print(ParamBase param) {
public void print(ParamSub param) {
System.out.println("I am Sub, the param is ParamSub");
}
public void println(){}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public void println(){}

不要修改多余的文件

}