Code example for TreeSet

0
     * Creates an empty {@code SortedSet} instance. 
     * 
     * @return a newly-created, initially-empty {@code SortedSet}. 
     */ 
    public static <E> SortedSet<E> newSortedSet() {
        return new TreeSet<E>();
    } 
 
    /** 
     * Creates a {@code SortedSet} instance containing the given elements. 
     * 
     * @param elements the elements that the set should contain 
     * @return a newly-created {@code SortedSet} containing those elements (minus 
     *     duplicates) 
     */ 
    public static <E> SortedSet<E> newSortedSet(E... elements) {
        SortedSet<E> set = new TreeSet<E>();
        Collections.addAll(set, elements);
        return set;
    }