TreeSet is not working properly
<p>The output does not sort in ascending order. Here is the code and the output I am getting.</p>

<p>The actual output is:</p>

<pre>
Amy Jose Jeremy Alice Patrick 
Alan Amy Jeremy Helen Alexi
</pre>

<p>While the expected output is:</p>

<pre>
Amy, Alice, Jeremy, jose, Patrick
Alan, Amy, Alexi, Helen, Jeremy
</pre>

<p>The code is:</p>

<pre><code>public class MyFriends
{
   static Set&lt;String&gt; names = new TreeSet&lt;String&gt;();

  public MyFriends()
   {
      super();
      names = new TreeSet&lt;String&gt;();
   }

  public static void exampleMethod()
   {
     String[] name1 = {"Amy", "Jose", "Jeremy", "Alice", "Patrick"};
     String[] name2 = { "Alan", "Amy", "Jeremy", "Helen", "Alexi"};

     for (int i = 0; i &lt; name1.length; i++)
     {
         names.add(name1[i]);
     }

     for (String aString : name1)
     {
       System.out.print(" " + aString);
     }

     for (int i = 0; i &lt; name2.length; i++)
     {
        names.add(name2[i]);
     }

     for (String bString : name2)
     {
       System.out.print(" " + bString); 
     }

   }    
</code></pre>
