Skip to content

Commit bdc8dd4

Browse files
committed
Student compareTo codes updated.
1 parent 93694bf commit bdc8dd4

File tree

1 file changed

+1
-4
lines changed
  • 02-Sorting-Basic/Course Code (Java)/02-Selection-Sort-Using-Comparable/src/bobo/algo

1 file changed

+1
-4
lines changed

02-Sorting-Basic/Course Code (Java)/02-Selection-Sort-Using-Comparable/src/bobo/algo/Student.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,12 @@ public Student(String name, int score){
1818
@Override
1919
public int compareTo(Student that) {
2020

21-
if( this.score == that.score )
22-
return this.name.compareTo(that.name);
23-
2421
if( this.score < that.score )
2522
return -1;
2623
else if( this.score > that.score )
2724
return 1;
2825
else // this.score == that.score
29-
return 0;
26+
return this.name.compareTo(that.name);
3027
}
3128

3229
// 定义Student实例的打印输出方式

0 commit comments

Comments
 (0)