Skip to content

Commit

Permalink
Student.equals练习
Browse files Browse the repository at this point in the history
  • Loading branch information
Consini committed Sep 10, 2019
1 parent 3058139 commit db46883
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions 09-10/src/Student.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* @ClassName Student
* @Author: K
* @create: 2019/9/10-20:38
**/
public class Student {
String sn;//学号
String name;
int age;
int gender;

@Override
public boolean equals(Object o){
//如果o为null或者o与Card不是一个类型,直接返回false
if(null == o || !(o instanceof Card)){
return false;
}
//如果o与this指向同一块区域返回true
if(this == o){
return true;
}
return sn.equals(((Student) o).sn);
}
}

0 comments on commit db46883

Please sign in to comment.