I am working in a small task that allow the user to enter the regions of any country and store them in one array. Also, each time he enters a region, the system will ask him to enter the neighbours of that entered region and store these regions.

My idea is each time the user enters the region, the system will store it in an arrya and each time he enters a region, the system will ask him to enter the neighbours of that region before he enters the second region and so on, and store these inputs in a second array under a pointer of the related entry in the first array.

what I did is just the beginning as follow:

```
import java.util.Arrays;
import java.util.Scanner;

public class Test {
   public static void main(String[] args) {

      Scanner kb = new Scanner(System.in);

      String [] regionArray = new String[5];

      for (int i = 0; i < regionArray.length; i++) {
         System.out.print("Please enter the region: ");
         regionArray[i] = kb.next();
         //kb.nextLine(); // to get and discard the nextline token
      }

      System.out.print("You have entered: ");

      System.out.println(Arrays.toString(regionArray));
   }
}

```

For example, assume we have 4 regions: a, b, c, d, and a has two neighbours: b and d. In this case when the user enters the first region which is (a), he will be asked to enter its neighbours which are b and d, then he will be able to enter the second region which is b and so on.

the problem now, How can I genereated the second array and make it linked to the first array?

**Please help me**

---

Thank you for your help. I really appreciate it.

Now I have used the Hashmap and everything is working well but I faced another problem in the retrieving specific region or neighbour. Besides that, I need to retrieve each one of them separatley in order to be able to apply four-colour theorem to each one of them, So how can I do that?

My Code was as following:

```
import java.util.*;
import java.util.HashMap;

public class Test5{
public static void main(String[]args){

HashMap<String, String> neighbour = new HashMap<String, String>();
Scanner kb = new Scanner(System.in);

for(;{
System.out.println ("Enter the neighbours first then the region... and when finished press q");

String n = kb.nextLine();
if (n.equalsIgnoreCase("Q"))
break;
System.out.print("region: ");
String region = kb.nextLine();
neighbour.put(region, n);
}

System.out.println(neighbour);

}
} 

```