I need to count the number of vowels in a list of words in Functional Java. If I have this list:
List<String> l = Arrays.asList("hello", "world", "test");
My idea was to "delete" the vowels and then do a subtraction this way:
int tot = l.stream().map(s -> s.replace("a", "")).
map(s -> s.replace("e", "")).
map(s -> s.replace("i", "")).
map(s -> s.replace("o", "")).
map(s -> s.replace("u", "")).
map(s -> s.length()).reduce(0, Integer::sum);
int res = l.stream().map(s->s.length()).reduce(0, Integer::sum)-tot;
Is there a better way to do this?