When I test it, it builds fine. But when I run it only the intro and user output questions come up (which is what it's supposed to do), but when I input an answer an error comes up: 

```
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 50
    at statecapitals.StateCapitals.main(StateCapitals.java:141)

```

Now I know i'm new at this but what I think the error is, is that my arrays are not corresponding and i'm not sure what I did wrong. Any help would much appreciated. Here is what I have:

```
    String[] stateName = new String[50];
    String[] capName = new String[50];

    int i;
    for(i=0; i < 50; i++)
    {
    stateName[0] = "Alabama";
    stateName[1] = "Alaska";
    .....
    capName[0] = "Montgomery";
    capName[1] = "Juneau";
    .....
    }

    boolean found = false;

    Scanner keyboard = new Scanner(System.in);
    System.out.println("This program is designed...");
    System.out.println("Please enter the name of a U.S. state (please enter capitalized):");
    stateName[i] = keyboard.nextLine();

    for(i=0; (!found) && (i < stateName.lenth); i++)
      if(stateName[i].matches(capName[i]) )
      System.out.print(The capital of " + stateName + " is " + capName);
      found = true;
        if(!found)
        System.out.println("The name you entered was not on the list.");

```

\*Updated & edited:
the line of code that was having the most trouble was:

```
    stateName[i] = keyboard.nextLine();

```

Thank you for everyone's help, i've made some changes:

```
    int i;
    for(i=0; i < 49; i++)
    {
    stateName[i+1]
    .....
    capName[i+1]
    ...
    }

```

Plus I added the curly brackets to my for loop at the bottom. Now when I run it, it stops on the line:

```
    if(capName[i].matches(stateName[i]) )

```

and the error this time is:

```
    Exception in thread "main" java.lang.NullPointerException
    at statecapitals.StateCapitals.main(StateCapitals.java:146)

```

Thank you again for everyone's input.