I’m trying to convert the following for loop into an enhanced for loop
for(int i=0; i< vowels.length; i++){
if(vowels[i] == Character.toLowerCase(c)){
return true;
}
}
return false;
This is what I got, but I got i == Character.isLetter(c) underlined because The operator == is undefined for the argument type(s) char, boolean. what’s wrong here?
for(char i: vowels){
if(i == Character.isLetter(c)){
return true;
}
}
return false;
Character.isLetter(c)returnsbooleannotchar. You can’t comparebooleanwithchar.You may need to do something like below:
EDIT: After your comment: Your code should be something like:
Note: Hand typed code, there may be syntax errors.