fork download
/* package whatever; // don't place package name! */

import java.util.*;
import java.util.function.*;
import java.util.stream.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Map<String, List<String>> groupsMap = new HashMap<>();
		groupsMap.put("1", new ArrayList<>());
		groupsMap.get("1").add("Jeff");
		groupsMap.get("1").add("Bob");
		groupsMap.put("2", new ArrayList<>());
		groupsMap.get("2").add("Jeff");
		
		String socialButterfly = groupsMap.values()
            .stream()
            .flatMap(Collection::stream)
            .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()))
            .entrySet()
            .stream()
            .max(Map.Entry.comparingByValue())
            .get()
            .getKey();
        System.out.println(socialButterfly);
	}
}
Success #stdin #stdout 0.25s 320960KB
stdin
Standard input is empty
stdout
Jeff