Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Person {
- public final String name;
- public final int age;
- public final String city;
- public Person(String name, int age, String city) {
- this.name = name;
- this.age = age;
- this.city = city;
- }
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- Person person = (Person) o;
- if (age != person.age) return false;
- if (name != null ? !name.equals(person.name) : person.name != null) return false;
- return city != null ? city.equals(person.city) : person.city == null;
- }
- @Override
- public int hashCode() {
- int result = name != null ? name.hashCode() : 0;
- result = 31 * result + age;
- result = 31 * result + (city != null ? city.hashCode() : 0);
- return result;
- }
- @Override
- public String toString() {
- return "Person{" +
- "name='" + name + '\'' +
- ", age=" + age +
- ", city='" + city + '\'' +
- '}';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement