Добрый день!
У меня есть код:
public static void main(String[] args) {
String verse = "Twinkle, twinkle, little star, \n" +
"How I wonder what you are. \n" +
"Up above the world so high, \n" +
"Like a diamond in the sky.";
int count = 0;
String[] words = verse.toLowerCase().split("[\\s.,?!\\d]+");
for (String word : words) {
if ((word.startsWith("a")) || (word.startsWith("e")) || (word.startsWith("i"))
|| (word.startsWith("o")) || (word.startsWith("u")) || (word.startsWith("y"))) {
count++;
}
}
System.out.println(count);
}
Как можно решить задачу другим способом, без
((word.startsWith("a")) || (word.startsWith("e")) || (word.startsWith("i"))
|| (word.startsWith("o")) || (word.startsWith("u")) || (word.startsWith("y")))