LogiQuest
Back to Java 8 Features
15

What is the output of the following program?

import java.util.*;
import java.util.stream.*;
public class Main {
    public static void main(String[] args) {
        Map<Integer, Long> byLen = Stream.of("to", "be", "or", "not").collect(java.util.stream.Collectors.groupingBy(String::length, TreeMap::new, java.util.stream.Collectors.counting()));
        System.out.println(byLen);
    }
}
Hard

Discussion (0)

  • No discussion yet. Ask a doubt or share a shortcut.

Log in to join the discussion.