String[] array = {"A", "X", "G", "X", "A"};
Set set = new HashSet(Arrays.asList(array));
String[] array2 = (String[])(set.toArray(new String[set.size()]));
A set is a collection object that cannot have a duplicate values, hence converting the array to a set removes the duplicate values.
No comments:
Post a Comment