String and Char Help



I have a few questions but first 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");
}
}

Question one is why does String1.length() return 70 when there are
only 69 chars. Second question is why does this code not count the
vowels in the String.

Thanks in advance

Robert

.



Relevant Pages

  • Re: Counting Chars Within Strings
    ... public class CountVowels ... int vowel = 0; ... pos = String1.charAt; ...
    (comp.lang.java.programmer)
  • Re: String and Char Help
    ... int vowel = 0; ... pos = String1.charAt; ... vowels in the String. ...
    (comp.lang.java.programmer)
  • Student.HELP.Why does this code not compile?
    ... // write the getLargest method here that will receive 3 integers and return ... public static int getLargest ... if it is vowel, return "false" otherwise ... // write countVowels method here that will receive a string and return the ...
    (comp.lang.java.programmer)
  • Student.HELP.Why does this code not compile?
    ... // write the getLargest method here that will receive 3 integers and return ... public static int getLargest ... if it is vowel, return "false" otherwise ... // write countVowels method here that will receive a string and return the ...
    (comp.lang.java.help)
  • Beginner: Gurus Why want this complie
    ... // write the getLargest method here that will receive 3 integers and return ... public static int getLargest ... if it is vowel, return "false" otherwise ... // write countVowels method here that will receive a string and return the ...
    (comp.lang.java)