Earlier on, in this thread my question was answered about how to add objects of a custom class I called State into a HashSet which was a value for a key in a HashMap.
Map<String, HashSet<State>> mapping = new HashMap<String, HashSet<State>>();
However, I need to ensure that there are only distinct State objects in this HashSet. The way that I know they are distinct is by a char that is stored within a State. However, the HashSet does not know that.
Can we please discuss a clear explanation of:
- The default behavior of a HashSet to ensure that the Set implementation functions
- How to change up my State class so that the HashSet knows on which value to check to ensure distinctness
This would be of great conceptual help to me for the future. Thank you!