Here you can find the source of asSet(Collection
static <T> HashSet<T> asSet(Collection<T> c)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { static <T> HashSet<T> asSet(Collection<T> c) { HashSet<T> ret = new HashSet<T>(); ret.addAll(c);/* ww w.jav a2s.co m*/ return ret; } }