Q:

cannot find symbol - variable name1 - TreeSet

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.
public class MyMates  
{

  public MyMates()
  {
    super();    
    names = new TreeSet<String>();  
  }

  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 < name1.length; i++) 
    {
     names.add(name1[i]);
    }
    System.out.println(names);

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

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

    Dialog.alert("repeated names not selected");
   }

A:

name1, name2 and name3 are local variables; their scope is limited to the method in which they are declared. Outside of that scope they have no meaning.

A:

Ok, try this: (I write it just for making work... in my opinion, it's an awful code)
import java.util.Set;
import java.util.TreeSet;

public class MyMates {

private static String[] name1 = null;
private static String[] name2 = null;
private static String[] name3 = null;
private static Set<String> names;

public MyMates() {
    methodASet();
    names = new TreeSet<String>();
}

public static void methodASet() {

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

public static void methodB() {

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

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

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

public static void main(String[] args) {
    MyMates polop = new MyMates();
    MyMates.methodB();
}
}

That prints:
[Alice, Amy, Jeremy, Jose, Patrick]
[Alan, Alexi, Alice, Amy, Helen, Jeremy, Jose, Patrick]
[Aaron, Adel, Alan, Alexi, Alice, Amy, Helen, James, Jeremy, Jose, Patrick]

