import java.util.*;
import java.lang.*;
import java.io.*;

import static java.util.stream.Collectors.counting;
import static java.util.stream.Collectors.groupingBy;

class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		List<String> list = Arrays.asList("a", "a", "d", "c", "d", "c", "a", "d");
		
		Map<String, Long> count = list.stream()
            .collect(
                groupingBy(
                    s -> s,
                    () -> new HashMap<>(), // Map<String, Long>
                    counting()
                )
            );
        System.out.println(count);
            
        count = list.stream()
            .collect(
                groupingBy(
                    s -> s,
                    () -> new HashMap<String, Long>(),
                    counting()
                )
            );
        System.out.println(count);
            
       /*count = list.stream()
            .collect(
                groupingBy(
                    s -> s,
                    () -> new HashMap<String, long[]>(),
                    counting()
                )
            );
        System.out.println(count);*/
	}
}