Advertisement
drSdGdBy

tipical override

Jan 11th, 2020
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.42 KB | None | 0 0
  1. @Override
  2.     public boolean equals(Object o) {
  3.         if (this == o) return true;
  4.         if (o == null || getClass() != o.getClass()) return false;
  5.         City city = (City) o;
  6.         return population == city.population &&
  7.                 Objects.equals(id, city.id) &&
  8.                 Objects.equals(name, city.name);
  9.     }
  10.  
  11.     @Override
  12.     public int hashCode() {
  13.         return Objects.hash(id, name, population);
  14.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement