Country-hashCode.java 797 B

12345678910111213141516171819202122232425262728293031323334
  1. public class Country {
  2. int population;
  3. double area;
  4. String name;
  5. @Override
  6. public int hashCode() {
  7. return 0;
  8. }
  9. @Override
  10. public boolean equals(Object obj) {
  11. if (this == obj)
  12. return true;
  13. if (obj == null)
  14. return false;
  15. if (getClass() != obj.getClass())
  16. return false;
  17. Country other = (Country) obj;
  18. if (Double.doubleToLongBits(area) != Double
  19. .doubleToLongBits(other.area))
  20. return false;
  21. if (name == null) {
  22. if (other.name != null)
  23. return false;
  24. } else if (!name.equals(other.name))
  25. return false;
  26. if (population != other.population)
  27. return false;
  28. return true;
  29. }
  30. }