I'm having difficulty getting very far with this task. All of the previous examples for removing an element from a set (and also every single result that comes up in Google searches) only uses string objects, which allows you to do:
And importantly, you can add the string in one method or constructor or wherever, and set.remove("string1") will work anywhere after that. But if I am creating other objects and storing those in the set, how do I refer to them outside of the function they're created in? createCats is where the Cat objects are created and stored in the HashSet which is returned. For example:
Cat cat1 = new Cat();
But when it comes time to remove something from cats in main, this does not work:
because it no longer knows what cat1 is.