If you don't want duplicates, use a Set instead of a List
. To convert a List
to a Set
you can use the following code:
// list is some List of Strings
Set s = new HashSet(list);
If really necessary you can use the same construction to convert a Set
back into a List
.