frequency of each element from list in java

Solutions on MaxInterview for frequency of each element from list in java by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
showing results for - "frequency of each element from list in java"
Lara
01 Sep 2020
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