Strings In Depth18 / 18
Up next

Chars as a stream

class Main {
    public static void main(String[] args) {
        String s = "programming";
        // count the vowels functionally
        long vowels = s.chars().filter(c -> "aeiou".indexOf(c) >= 0).count();
        System.out.println(vowels);
    }
}
What you're solving

chars() gives an IntStream