static int countIntersection(Set a, Set b) { if (a == null || b == null) ret 0; int n = 0; for (A x : a) if (b.contains(x)) ++n; ret n; }