-7

Im getting compile error when I tried instantiating above method with this:

new HashMap<String, new HashMap<String, JsonNode>()>()

Thanks

Please see the error here

Assafs
  • 3,257
  • 4
  • 26
  • 39
PhaYo
  • 1
  • 3

1 Answers1

2

When you call the constructor, you can use Diamond Inference to tell the compiler to "figure it out":

Map<String, Map<String, JsonNode>> myMap = new HashMap<>();

If you really want to declare the whole type, then it's similar to the variable declaration. You only use the parenthesizes when you call the constructor, not for each generic type:

Map<String, Map<String, JsonNode>> myMap = new HashMap<String, Map<String, JsonNode>>();
rhobincu
  • 906
  • 1
  • 7
  • 22