Counting Char's Within Strings



Alright a couple of stupid questions here about strings and Chars.
First off here is my Code

public class CountVowels
{
public static void main(String[] args)
{
int vowel = 0;
int i;
char pos;
String String1 = "Event Handlers is dedicated to making your
event a most memorable one.";
int length = String1.length();
for(i = 0; i < length - 1 ; i++);
{
pos = String1.charAt(i);
if (pos == 'A' || pos == 'a' || pos == 'E' || pos == 'e' ||
pos == 'I' || pos == 'i' || pos == 'O' || pos == 'o' || pos == 'U' ||
pos == 'u') {
vowel += 1;
}
}
System.out.println("There are " + vowel + " vowels in this
String");
}
}

First question is why does String1.length() return 70 when I only
count 69? The other question is why does this code always produce 0
vowels?

Thanks in advance I am just a little stumped.

.



Relevant Pages

  • String and Char handling limitations:
    ... Why does Pascal limit functions you can perform on Strings and Chars. ... However that method is causing an infinite loop and there is no way a ...
    (comp.lang.pascal.borland)
  • Re: String and Char handling limitations:
    ... Why does Pascal limit functions you can perform on Strings and Chars. ... However that method is causing an infinite loop and there is no way a ...
    (comp.lang.pascal.borland)
  • Re: Howto Distinguish Prior from KP_Prior
    ... dumped the read chars in hex. ... That's not quite as nifty as the keymap feature, ... few days ago, with strings like: ... So you push the key that generates keysym 0xffb9, rxvt inserts ...
    (comp.os.linux.x)
  • Re: Curses - can I use utf-8 with the form and menu libraries ?
    ... > the form library doesn't accept the strings, ... > isprintreturnes false for those chars. ... buffer which holds the translation (this may be a problem with some ...
    (comp.unix.programmer)
  • Re: directory name length limitation
    ... > the limitation of ~255 chars per level is easy to understand, ... > but why these 4095 chars in a system call? ... Handling longer strings in the kernel would be possible, ...
    (comp.os.linux.development.system)