[Edit] Forget the following...
It depends on the class.
If it implements the Set interface then a reference to the object will occur at most once. So just use contains() to see if it's there or not.
Otherwise use the fact that Collection extends Iterable and ... iterate over the class counting the numebr of times it contains a reference to the object you are interested in.