Java tutorial
//package com.java2s; /* * Copyright: Copyright 2010 Topic Maps Lab, University of Leipzig. http://www.topicmapslab.de/ * License: Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0.html * * @author Sven Krosse * @email krosse@informatik.uni-leipzig.de * */ import java.util.Collection; import java.util.HashSet; import java.util.Set; public class Main { /** * Transformation operation for a {@link Collection} to a {@link Set}. * * @param <E> * the type of the given and returned values * @param collection * the collection to transform * @return the new {@link Set}, containing all entries of the given * collection */ public static <E extends Object> Set<E> asSet(Collection<E> collection) { Set<E> hashSet = new HashSet<E>(); hashSet.addAll(collection); return hashSet; } }