Sunday, August 4, 2002 11:00 PM
I am inserting objects of type Person into a HashSet. This class has an 'equals' method that returns true or false based on its instance variable 'name' of type String. Now, if I try to insert an object of type Person into the HashSet, no problem. If i try to remove an object already in the hash set, then there is a problem. It turns out that it will remove the object if I use the same exact reference to specify what object to remove. For instance:
Person bob = new Person("Bob");
This code works fine. However, this piece of code does not work:
How come? The 'equals' method matches the object based on their 'name' variable.
Re: Deleting elements from Hash Set
Monday, August 5, 2002 12:20 AM