Java tutorial
//package com.java2s; import java.util.Collection; public class Main { public static int cardinality(Object obj, Collection coll) { int i = 0; for (Object o : coll) { if (o.equals(obj)) { i++; } } return i; } }