I need to initialize an ImmutableMap (guava 21.0) and I need it to resolve to a Map> for this example I will just use String.
So I have:
import com.google.common.collect.ImmutableMap;
public class MyClass {
private Map<String,String> testMap =
ImmutableMap<String,String>.builder().put("a","b").build();
and on that last line I get a huge amount of compiler errors. The use of ImmutableMap<String,String>.of()
gets the same result.
If I remove I just get one error, a type mismatch.
How can I use ImmutableMap for explicit (literal-like) initialization when I do want a map with explicit types?