Java
1public static void main(String[] args) throws Exception {
2 int[] x = { 0, 1, 1, 2 };
3 Map<Integer, Long> summary = Arrays.stream(x).boxed().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
4 System.out.println("0が" + summary.get(0) + "個"); // 0が1個
5 System.out.println("1が" + summary.get(1) + "個"); // 1が2個
6 System.out.println("2が" + summary.get(2) + "個"); // 2が1個
7}