Created
October 9, 2021 13:16
-
-
Save nowshad-hasan/c377ec8d29b68a0398b8ee21b43c5a6b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OldStudent{ | |
private String name; | |
private int age; | |
public OldStudent(String name, int age) { | |
this.name = name; | |
this.age = age; | |
} | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public int getAge() { | |
return age; | |
} | |
public void setAge(int age) { | |
this.age = age; | |
} | |
@Override | |
public boolean equals(Object o) { | |
if (this == o) return true; | |
if (o == null || getClass() != o.getClass()) return false; | |
OldStudent student = (OldStudent) o; | |
return age == student.age && | |
Objects.equals(name, student.name); | |
} | |
@Override | |
public int hashCode() { | |
return Objects.hash(name, age); | |
} | |
@Override | |
public String toString() { | |
return new StringJoiner(", ", OldStudent.class.getSimpleName() + "[", "]") | |
.add("name='" + name + "'") | |
.add("age=" + age) | |
.toString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment