Here you can find the source of toSet(List
public static Set<Object> toSet(List<Object> sources)
//package com.java2s; //License from project: Open Source License import java.util.Collections; import java.util.List; import java.util.Set; public class Main { public static Set<Object> toSet(List<Object> sources) { Set<Object> targets = Collections.emptySet(); targets.addAll(sources);//from w w w . java 2 s.c om return targets; } }