First, the given string is split into the array by using the String.split() method. After that, the Arrays.stream() method returns a stream of the passed array.
The second intermediate operation is to convert the string into lowercase letters. For the same, we have used the Stream.map() method that returns a stream consisting of the results of applying the given function to the elements of this stream.
The collect() function is used to perform a mutable reduction operation and concatenate the list elements. The Collectors.groupingBy() method returns a Collector implementing a cascaded "group by" operation on input elements of type T.
In order to count the elements, we have used the counting() method of the Collectors class. The method returns a Collector accepting elements of type T. It counts the number of input elements, if no elements are present, the result is 0.
https://www.javatpoint.com/java-program-to-count-occurrences-of-each-character