char[] task = new char[]{'a', 'b', 'c', 'c', 'd', 'e'}; Map<Character, Long> map = IntStream.range(0, task.length) .mapToObj(idx -> task[idx]).collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter