subroutine taking an array as a parameter in Java
<p>In the following program, the user is supposed to enter a <code>String</code> (name of a City) and the program should return the index of the corresponding City in the array.</p>

<p>But I get an error, in the subroutine <code>indexCities</code> the following message: </p>

<blockquote>
  <p>"nameCity cannot be resolved".</p>
</blockquote>

<p>I guess it is a problem of variable scoping but I don't figure out how I should do.
Thanks for your help.</p>

<pre><code>import java.util.Scanner;

public class villes {

    public static void main(String[] args) {
        String cities[] = {"Vierzon","Salbris","Nouans","LB","LFSA","Orleans"};
        Scanner input = new Scanner(System.in);
        String nameCity = input.nextLine();
        indexCities(cities);
    }

    public static int indexCities(String cities[]) {
        for (int i = 0; i &lt; cities.length; i++) {
            if(nameCity.equals(cities[i])) {
                System.out.println(i);
                break;
            }
        }
    }

}
</code></pre>