Here you can find the source of toTreeSet(Collection
public static TreeSet<String> toTreeSet(Collection<String> lines)
//package com.java2s; //License from project: Open Source License import java.util.Collection; import java.util.TreeSet; public class Main { public static TreeSet<String> toTreeSet(Collection<String> lines) { TreeSet<String> tree = new TreeSet<String>(); for (String em : lines) { tree.add(em);//from w ww .j a v a 2s .com } return tree; } }