Here you can find the source of count(V matching, Collection
public static <V> int count(V matching, Collection<V> values)
//package com.java2s; //License from project: Apache License import java.util.Collection; public class Main { /************************************************************************/ public static <V> int count(V matching, Collection<V> values) { int count = 0; for (V value : values) { if (matching.equals(value)) { count++;// w ww. j av a 2s . c om } } return count; } }