I asked a previous question about how I would save multiple save files to a .ser file, and I was suggested to use a hashset because they are serializable. I have tried to write
Solution: Serialize the hashset itself. Just make sure testClass implements Serializable and all of its fields do so to.
When you want to unserialize it and read the object, you cast it to HashSet<testClass> and it will maintain its state as before you serialized it.
HashSet<testClass>