リストに格納されている要素の頻度を取得しようとしています。
次の ID をリストに保存しています
ID
1
2
1
3
3
4
4
4
次の出力が必要です。
ID| Count
1 | 2
2 | 1
3 | 2
4 | 3
Javaでは、次の方法で実行できます。
for (String temp : hashset)
{
System.out.println(temp + ": " + Collections.frequency(list, temp));
}
ソース: http://www.mkyong.com/java/how-to-count-duplicated-items-in-java-list/
c#でリストの頻度カウントを取得するには?
ありがとう。