Demo

package edu.xcdq.tools;

import com.sun.xml.internal.fastinfoset.stax.factory.StAXOutputFactory;

import java.util.Arrays;
import java.util.HashSet;
import java.util.logging.Handler;

/**
 * @author yuhuicun
 * @date 2021/5/10 8:13
 */
public class Demo02 {
    public static void main(String[] args) {
        String str [] = {"中文","计算机","ABC"};
        // 1 将数组转换成集合
        HashSet set = new HashSet<>(Arrays.asList(args));
        System.out.println(set);
        // 2 集合转换成数组
        Object[] arr = set.toArray();
        for (Object a : arr){
            System.out.println(a);
        }

    }
}

你可能感兴趣的:(Demo)