Source Code : Generic collection conversion: HashSet and ArrayList
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Generic collection conversion: HashSet and ArrayList
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class Capture {
static <T> Set<T> listToSet(List<T> list) {
Set<T> set = new HashSet<T>();
set.addAll(list);
return set;
}
public static void main(String[] args) {
List<?> list = new ArrayList<Date>();
Set<?> set = listToSet(list);
}
}
Thank with us