📅  最后修改于: 2022-03-11 14:56:46.110000             🧑  作者: Mango
List arr = Arrays.asList("a", "a", "b", "a", "a");
Set printed = new HashSet<>();
for (String s : arr) {
if (printed.add(s)) // Set.add() also tells if the element was in the Set!
System.out.println("element: " + s
+ ", count: " + Collections.frequency(arr, s));
}