I have an ArrayList, and I want to remove repeated strings from it. How can I do this?
ArrayList
This three lines of code can remove the duplicated element from ArrayList or any collection.
List entities = repository.findByUserId(userId); Set s = new LinkedHashSet(entities); entities.clear(); entities.addAll(s);