怎么去掉字符串数组中重复的值
1个回答
展开全部
import java.util.Set;
import java.util.TreeSet;
public class Admin {
public static void main(String[] args) {
String fdbs = "WXB,WXA,FDA,WXB";
String[] str = fdbs.split(",");
Set set = new TreeSet();
for (int i = 0; i < str.length; i++) {
set.add(str[i]);
}
str = (String[]) set.toArray(new String[0]);
for (int i = 0; i < str.length; i++) {
System.out.println(str[i]);
}
}
}
import java.util.TreeSet;
public class Admin {
public static void main(String[] args) {
String fdbs = "WXB,WXA,FDA,WXB";
String[] str = fdbs.split(",");
Set set = new TreeSet();
for (int i = 0; i < str.length; i++) {
set.add(str[i]);
}
str = (String[]) set.toArray(new String[0]);
for (int i = 0; i < str.length; i++) {
System.out.println(str[i]);
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询