add equals method
This commit is contained in:
parent
937f0fb784
commit
d0678c77ab
@ -1,6 +1,7 @@
|
|||||||
package com.baeldung.crypto;
|
package com.baeldung.crypto;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Student implements Serializable {
|
public class Student implements Serializable {
|
||||||
private String name;
|
private String name;
|
||||||
@ -26,4 +27,14 @@ public class Student implements Serializable {
|
|||||||
public void setAge(int age) {
|
public void setAge(int age) {
|
||||||
this.age = age;
|
this.age = age;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
|
return false;
|
||||||
|
Student student = (Student) o;
|
||||||
|
return age == student.age && Objects.equals(name, student.name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user