Fight With Me!!!

导航

(Java)怎么去掉字符串数组中重复的值?

        String fdbs = "WXB,WXA,FDA,WXB";
        String[] str = fdbs.split(",");
        Set set = new HashSet();
        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]);
        }

 

posted on 2018-04-17 16:42  nickTimer  阅读(3769)  评论(0编辑  收藏  举报