Answers for "frequency of element in list java"

0

frequency of each element from list in java

public static void main(String[] args)
    {
        List<String> list = Arrays.asList("B", "A", "A", "C", "B", "A");

        Set<String> distinct = new HashSet<>(list);
        for (String s: distinct) {
            System.out.println(s + ": " + Collections.frequency(list, s));
        }
    }
}
Posted by: Guest on October-04-2021

Code answers related to "frequency of element in list java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language