Java tutorial
import java.util.Collections; import java.util.Set; import java.util.TreeSet; public class Main { public static void main(String args[]) { Set<String> hset = new TreeSet<String>(); // populate the set hset.add("from"); hset.add("java2s.com"); hset.add("tutorial"); // get typesafe view of the set Set<String> tsset = Collections.checkedSet(hset, String.class); System.out.println(tsset); } }