public class InstrumentedHashSet<E> extends HashSet<E> {
private int addCount = 0;
@Override
public boolean add(E e){
addCount++;
return super.add(e);
}
public static void main(String[] args) {
InstrumentedHashSet<String> s = new InstrumentedHashSet<String>();
s.addAll(Arrays.asList("Accordion","Banjo","Kazoo"));
System.out.println(s.addCount);
}
}