title: Java: Check if two objects of the same class have identical values
body: <p>I want to know how to check if two objects of the same class have the same values ​​in each attribute.</p>
  
  <p>For example:</p>
  
  <pre><code>public class Person {
  String name;
  String surname;
  String country;
  int age;    
  
  public Person(String name, String surname, String country, int age) {
      this.name = name;
      this.surname = surname;
      this.country = country;
      this.age = age;
  }
  
  public boolean samePerson(Person person){
      //CODE
  }
  
  
  Person person1 = new Person("Abel", "Smith", "EEUU", 26);
  Person person2 = new Person("Alexa", "Williams", "Canada", 30);
  Person person3 = new Person("Abel", "Smith", "EEUU", 26);
  Person person4 = new Person("Alexa", "Williams", "EEUU", 30)
  
  
  person1.samePerson(person2) // return false
  person1.samePerson(person3) // return true
  person2.samePerson(person3) // return false
  person2.samePerson(person4) // return false
  </code></pre>
  
  <p>The only thing I can think of is to compare the attributes one to one. Is there a simpler way?</p>
  
  <p>Sorry for my english</p>
  
  <p>Thanks in advance</p>