From 5ac2ec2fdc0621a465b1b5487e72e1dcf475e6ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cidpeng=E2=80=9D?= <630606938@qq.com> Date: Thu, 26 Aug 2021 09:44:42 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A6=86=E7=9B=96toString=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/github/hcsp/inheritance/User.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/github/hcsp/inheritance/User.java b/src/main/java/com/github/hcsp/inheritance/User.java index 1d2c8df..72e0f1a 100644 --- a/src/main/java/com/github/hcsp/inheritance/User.java +++ b/src/main/java/com/github/hcsp/inheritance/User.java @@ -17,6 +17,14 @@ public String getName() { return name; } + @Override + public String toString() { + return "User{" + + "id=" + id + + ", name='" + name + '\'' + + '}'; + } + public static void main(String[] args) { System.out.println(new User(1, "user1")); }