cannot find symbol - variable name1 - TreeSet
<p>In methodB I have done a for loop where duplicate names are not displayed. If I do this for loop in methodASet it will work. When I try to do this in methodB I get a error message "cannot find symbol - variable name1". Normally I use this.nameofthemethodheader();, but I now know I can't do this for TreeSet. Could anyone be kind enough help me here? Here is the code. Thank you. Bear in mind I want to use this for loop that I have done.</p>

<pre><code>public class MyMates  
{

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

  public static void methodASet()
  {

    String[] name1 = new String[] {"Amy", "Jose", "Jeremy", "Alice", "Patrick"};
    String[] name2 = new String[] { "Alan", "Amy", "Jeremy", "Helen", "Alexi"};
    String[] name3 = new String[] { "Adel", "Aaron", "Amy", "James", "Alice" };
  }

public static void methodB()
    {


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

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

    for (int i = 0; i &lt; name3.length; i++)
    {
       names.add(name3[i]);
    }   
    System.out.println(names);


    Dialog.alert("repeated names not selected");
   }
</code></pre>
