Java tutorial
//package com.java2s; import java.util.HashSet; import java.util.List; import java.util.Set; public class Main { /** * <p>Turn source list to Set</p> * @param list source list * @return */ public static <T extends Object> Set<T> turnListToSet(List<T> list) { Set set = new HashSet<T>(); if (list != null) { for (T obj : list) { set.add(obj); } } return set; } }