From 486c671e9e2a0545b6f5ce0c397764559f408018 Mon Sep 17 00:00:00 2001 From: XT <871963417@qq.com> Date: Thu, 28 Apr 2022 23:34:41 +0800 Subject: [PATCH] Change compareTo(), name.charAt, getId, done. --- src/main/java/com/github/hcsp/polymorphism/User.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/github/hcsp/polymorphism/User.java b/src/main/java/com/github/hcsp/polymorphism/User.java index 7a601df..cf3195d 100644 --- a/src/main/java/com/github/hcsp/polymorphism/User.java +++ b/src/main/java/com/github/hcsp/polymorphism/User.java @@ -47,7 +47,16 @@ public int hashCode() { /** 老板说让我按照用户名排序 */ @Override public int compareTo(User o) { - return name.compareTo(o.name); + if(name.charAt(0)o.name.charAt(0)){ + return 1; + } + if(this.getId()