I have an ArrayList<String>, and I want to remove repeated strings from it. How can I do this?
I have an ArrayList<String> , and I want to remove repeated strings from it.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you don’t want duplicates in a
Collection, you should consider why you’re using aCollectionthat allows duplicates. The easiest way to remove repeated elements is to add the contents to aSet(which will not allow duplicates) and then add theSetback to theArrayList:Of course, this destroys the ordering of the elements in the
ArrayList.