📌  相关文章
📜  java代码示例中列表中每个元素的频率

📅  最后修改于: 2022-03-11 14:52:47.181000             🧑  作者: Mango

代码示例1
public static void main(String[] args)
    {
        List list = Arrays.asList("B", "A", "A", "C", "B", "A");

        Set distinct = new HashSet<>(list);
        for (String s: distinct) {
            System.out.println(s + ": " + Collections.frequency(list, s));
        }
    }
}