@Test
public void test4() {
String[] before = new String[]{"a", "b", "c", "a","5","x","c"};
String[] strings = test3(before);
System.out.println(Arrays.toString(strings));
}
public String[] test3(String[] before) {
//Arrays.asList() :把数组转换成list集合
List<String> list = Arrays.asList(before);
//把list集合转成set集合,
Set<String> set = new HashSet<>(list);
String[] str = new String[set.size()];
//set.toArray(str) : 将set集合中的元素装到数组中,
//注意:该数组和该集合的大小一定要相等!!!
String[] sss = set.toArray(str);
//return set.toArray(str);
return sss;
}