Is there a way to achieve something like this? This code is similar to what I want to achieve.
public static void main(String[] args){
MultiCall(new HashMap<Integer, Integer>(){{
put(1, 2);
put(3, 4);
}}, (i, j) -> {
System.out.println(i + j);
});
}
public void MultiCall(HashMap<?, ?> map, BiConsumer<? super ?, ? super ?> func){
...
map.forEach(func);
}
The problem here is BiConsumer, I need the wildcard to be the super of HashMap's wildcard.
The linter says this
Required type: BiConsumer <? super capture of ?, ? super capture of ?>
However, upon doing ? super ?
, says it need to be a Type. But the Type currently is a wildcard.