I am facing a problem while writing my code. I am using HashSet in java.
I have the requirement that if a object does not exist in hashset, then add that particular object using add() method.
But if the object already exists, I need that particular object to save somewhere else. But I don't see get() method for hashset in java. Could someone please help?
Is there any way to get the object from HashSet or please suggest some other data structure.