This question already has an answer here:
I was writing code to determine if a given character is a vowel. There was a portion of my code that seemed as if it could use some simplification. The code is as follows:
public static boolean isVowel(char s) {
if (s == 'a' || s == 'e' || s == 'i' || s == 'o' || s == 'u' || s == 'A' || s == 'E' || s == 'I' || s == 'O' || s == 'U') {
return true;
}
return false;
}
I would not like to write '|| s ==' o frequently. Could I change this?
Aucun commentaire:
Enregistrer un commentaire