In java, you can add Type parameters to static methods, to create methods that handle generics. Can you do the same with lambdas?
In my code I have
final private static <K,V> Supplier<Map<K, List<V>> supplier=HashMap::new;
I'm trying to do type parameters like it's a function, but it won't let me.
And if I do:
final private static Supplier<Map<?, List<?>>> supplier=HashMap::new;
It doesn't accept the argument where I try to use it. What can I do?
WhateverClassThatSupportsGenerics<?> var = ...;unless it's a parameter of a method.new HashMap<Integer, List<?>>is legal, butnew HashMap<?, List<?>>is not.?means "I don't know what type this HashMap uses," but when you create a HashMap, you always know what you intend to put in it (even if you decide it's java.lang.Object).HashMap<?, ?> map=new HashMap<>();without specifying actual type arguments. Though such a map would not be of much use…