Java: Array element as a number
<p>I need to get a number of position of array element.</p>

<p>Here's the code:</p>

<pre><code>private static char Ranks[] = {'soldier', 'corporal', 'mayor', 'general'}; 
</code></pre>

<p>Now I need to get the number where each rank is assigned to:</p>

<pre><code>public static int getRank(MilitaryPerson mp) {
    int number = 0;
    for (int i = 0; i &lt; Rank.values().length; i++){
        if ()
            {
                number = 1;// or 2 or 3...
            }
            return number;
        }
    }
}
</code></pre>

<p>Soldier is assigned to Ranks[0], then 0 should be returned by getRank etc.</p>
