How to create a list of unique/distinct objects (no duplicates) in Java?
Right now I am using HashMap<String, Integer>
to do this as the key is overwritten and hence at the end we can get HashMap.getKeySet()
which would be unique. But I am sure there should be a better way to do this as the value part is wasted here.