This example will find the number of occurrences of a character in a string using groovy. We will use the string count method, findAll passing a closure and convert the string to a char array passing in the ASCII value to the count method. A comparable example we demonstrate how to count instances of a character in string using java, java 8, guava, apache commons and spring framework.
Count chars in string
Find all chars in string
If you didn't like the ease of count above, you could filter then find the size of the resulting collection.