// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.util.*;

public class Frequency {
    public static void main(String[] args) {
        ArrayList<Hej> a = new ArrayList<Hej>();
        Hej o = new Hej(1);
        a.add(o);
        a.add(o);
        a.add(o);
        a.add(new Hej(1));
        a.add(new Hej(1));
        System.out.println(Collections.frequency(a,o));
   }
}

class Hej {
    private int t;
    public Hej(int d) {
        t = d;
    }
    public boolean equals(Object h) {
        return t == (((Hej)h).t);
    }
}
