I am trying to create a method in java that will scan for the location of the first vowel in a string, below is my code:
int x = 0;
String vowel = "aiueo",st = "";
boolean found = false;
for (int i = 0; i <= s.length()-1 && (found = false); i++ )
{
if (vowel.indexOf(s.charAt(i)) != -1)
{
st = s.charAt(i);
found = true;
}
}
x = s.indexOf(st);
return x;
}
but it generates a compiler error:
C:\Documents and Settings\Aditya Aditama H\My Documents\CSC\test\WordProcessor.java:172: incompatible types
found : char
required: java.lang.String
st = s.charAt(i);
why is that?
2006-10-29
10:20:17
·
3 answers
·
asked by
Anonymous
in
Computers & Internet
➔ Programming & Design