1 public static void main(String[] args)
2 {
3 List<String> list = Arrays.asList("B", "A", "A", "C", "B", "A");
4
5 Set<String> distinct = new HashSet<>(list);
6 for (String s: distinct) {
7 System.out.println(s + ": " + Collections.frequency(list, s));
8 }
9 }
10}
11