How to create a list of unique/distinct objects (no duplicates) in Java?
Right now I am using HashMap to do this as the key is o
HashMap
I do not know how efficient this is, However worked for me in a simple context.
List<int> uniqueNumbers = new ArrayList<>(); public void AddNumberToList(int num) { if(!uniqueNumbers .contains(num)) { uniqueNumbers .add(num); } }