📅  最后修改于: 2022-03-11 14:52:47.181000             🧑  作者: Mango
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));
}
}
}