Prevent recursive function from causing an "out of bounds" error
<p>I have been working on a program to count vowels in inputted text. It uses this method to recursively add to a vowel count every time a vowel is found. However, I get an out of bounds error every time <code>lastPos</code> reaches negative 1. How can I get this to stop once <code>lastPos</code> reaches -1?</p>

<pre><code>static int R_countVowels(String s, int lastPos) 
{           
    switch (s.charAt(lastPos))
    {  case 'a': case 'A':
       case 'e': case 'E':
       case 'i': case 'I':
       case 'o': case 'O':
       case 'u': case 'U': return (1 + R_countVowels(s, --lastPos));
       default: return R_countVowels(s, --lastPos);
    }
}
</code></pre>
