forEach on HashMap and IdentityHashMap

Dawid Weiss dawid.weiss at
Wed Jun 12 10:36:10 UTC 2013

> default void forEach(BiConsumer<? super K, ? super V> sink) {

It would be nice to specify it as in here:

public <T extends BiConsumer<? super K,? super V>> T forEach(T sink)

funny as it looks, it allows the caller to create an anonymous class
instance and get at its methods/ fields in a call chain.

int counted = map.forEach(new BiConsumer<X,Y>() {
  public int counter;
  // the rest of the implementation...

Just a thought.


More information about the core-libs-dev mailing list