【去除集合中字符串的重复值-3】

package com.yjf.esupplier.common.test;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;

/**
 * @author shusheng
 * @description
 * @Email [email protected]
 * @date 2018/12/12 17:11
 */
public class ArrayListDemo2 {

    public static void main(String[] args) {

        ArrayList array = new ArrayList();
        array.add("hello");
        array.add("world");
        array.add("world");
        array.add("world");
        array.add("java");
        array.add("java");
        array.add("hello");
        array.add("hello");
        array.add("software");

        HashSet hs = new HashSet();
        hs.addAll(array);

        Iterator it = hs.iterator();
        while(it.hasNext()){
            System.out.println(it.next());
        }

    }

}

猜你喜欢

转载自www.cnblogs.com/zuixinxian/p/10340840.html
今日推荐