Convert List of Object to Set of Object - Java java.util

Java examples for java.util:List Convert

Description

Convert List of Object to Set of Object

Demo Code


//package com.java2s;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Main {
    public static void main(String[] argv) {
        List tList = java.util.Arrays.asList("asdf", "java2s.com");
        System.out.println(setList2Set(tList));
    }/* ww  w  .  j  a  va2s.  c om*/

    public static Set setList2Set(List<?> tList) {
        Set<?> tSet = new HashSet(tList);
        return tSet;
    }
}

Related Tutorials