From 61f6aff8f2a205bb1ce844640acbeb818b96d0ea Mon Sep 17 00:00:00 2001 From: niuweizhe Date: Thu, 3 Dec 2020 21:53:40 +0800 Subject: [PATCH 1/2] create a instance method --- src/main/java/com/github/hcsp/Home.java | 1 + src/main/java/com/github/hcsp/pet/Cat.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/com/github/hcsp/Home.java b/src/main/java/com/github/hcsp/Home.java index 004c169..a8a97b8 100644 --- a/src/main/java/com/github/hcsp/Home.java +++ b/src/main/java/com/github/hcsp/Home.java @@ -12,4 +12,5 @@ public static void main(String[] args) { white.name = "White"; white.sayName(); } + } diff --git a/src/main/java/com/github/hcsp/pet/Cat.java b/src/main/java/com/github/hcsp/pet/Cat.java index 163caaf..1aa199e 100644 --- a/src/main/java/com/github/hcsp/pet/Cat.java +++ b/src/main/java/com/github/hcsp/pet/Cat.java @@ -6,5 +6,6 @@ public class Cat { public void sayName() { // Print itself's name to standard output (System.out) here // 在这里将自己的名字打印到标准输出(System.out) + System.out.println(name); } } From 05706439d793c8dc099358a6c52efb258e165bf2 Mon Sep 17 00:00:00 2001 From: Diesel Niu Date: Thu, 3 Dec 2020 22:21:16 +0800 Subject: [PATCH 2/2] Update Cat.java --- src/main/java/com/github/hcsp/pet/Cat.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/github/hcsp/pet/Cat.java b/src/main/java/com/github/hcsp/pet/Cat.java index 1aa199e..c4f7e47 100644 --- a/src/main/java/com/github/hcsp/pet/Cat.java +++ b/src/main/java/com/github/hcsp/pet/Cat.java @@ -6,6 +6,6 @@ public class Cat { public void sayName() { // Print itself's name to standard output (System.out) here // 在这里将自己的名字打印到标准输出(System.out) - System.out.println(name); + System.out.println(this.name); } }