Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
値のリストを格納している配列リストがあります。リストに同じ値が複数回含まれているかどうかを確認する必要があります。繰り返しのない値のみが必要です。配列リスト内の値の存在数を確認するにはどうすればよいですか?
前もって感謝します..
使用する
public static intfrequency(コレクションc、オブジェクトo)
コレクション(arraylist)内のオブジェクトの頻度を取得します。
これがあなたがそれをすることができる方法です:
ArrayList<String>numbers= new ArrayList<String>(); numbers.add("1"); numbers.add("2"); numbers.add("1"); numbers.add("3"); int count= Collections.frequency(numbers, "1");
このようにして、countは2を返します。