title: How can I remove an object of type X from a hashtable given one unique attribute of X in Java?
body: <p>Let's say I have a class person</p>
  
  <pre><code>public class Person {
  
  int personID = 123;
  String fname = John;
  String lname = Doe;
  
  }
  </code></pre>
  
  <p>and I've created a hashtable . (using person as both a key and value).
  Now, assuming each person has a unique ID and assuming the hashtable is full of persons, I want, given a unique ID (int), to remove the person from the hashtable corresponding to that ID.</p>
  
  <p>The problem arises with what parameters to give the hashtable.remove() function since it takes an object of type Person and not an int.</p>
  
  <p>Note: assume the fact that the key and value are both of type Person is a design requirement and cannot be changed</p>
  
  <p>Edit: I have overriden the hashcode() and equals() method of the person class, they both rely on the personID now. But I still don't know what to pass the hashtable.remove() method since it takes type Person and I want to remove based on a user-given int (which is the personID)</p>