Java tutorial
import java.util.Arrays; import java.util.stream.Collectors; public class Main { public static void main(String[] args) { System.out.println("counting " + Arrays.asList(1, 20, 40, 4).stream().collect(Collectors.counting())); } }