title: How do I determine whether two instances of a Student class represent the same student?
body: <p>I have a Java class</p>
  
  <pre><code>class Student
  {
      String name;
      int age;
  }
  </code></pre>
  
  <p>Also, I have two instances of the Student class <code>student1</code> and <code>student2</code>.</p>
  
  <p>One way to find out whether both the instances represent the "same student" is to compare the data manually, i.e., the name and age. If they are the same, then they represent the "same student".</p>
  
  <p>Is there any other way to find out whether the two instances represent the "same student"?</p>
  
  <p>P.S. I was asked this question in an interview. I still do not fully understand the phrase "same student". I am guessing it means same student in the real world. If not, what else could the interviewer have meant?</p>