import java.util.TreeSet;
import java.util.Iterator;

class TreeSetHelper
 {TreeSet t = new TreeSet();

   public void add(Object o)
     {if (t.contains(o))
      {System.out.println("Error, already contains object");
       return;
       }
       t.add(o);
       }

    public void print()    // a TreeSet will print out inorder
     {Iterator it = t.iterator();
      while (it.hasNext())
       {System.out.println(it.next());
       }
      }

     public void remove(Object o)
      {t.remove(o);
      }

     public int size()
      {return t.size();
      }
     }
**************************************

import java.io.*;

public class TreeSetDriver
{
public static void main(String[] args) throws IOException
 {TreeSetHelper t = new TreeSetHelper();
  t.add("Mary");
  t.add("Tom");
  t.add("Ellen");
  t.add("Jack");
  t.add("Joe");
  t.add("Kelly");
  t.add("Nancy");
  t.add("Bob");
  t.print();
  t.remove("Jack");
  System.out.println();
  t.print();
  }
  }