Java tutorial
//package com.java2s; import java.util.Collection; public class Main { public static <T> int countCommonElements(Collection<T> c1, Collection<T> c2) { int nbCommon = 0; for (T e : c1) { if (c2.contains(e)) { nbCommon++; } } return nbCommon; } }