Iterating over a map entryset

后端 未结 6 967
生来不讨喜
生来不讨喜 2020-12-16 13:37

I need to iterate over the entry set of a map from which I do not know its parameterized types.

When iterating over such entryset, why this does not compile ?

<
6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-16 13:55

    the first code snippet wont compile because the variable map does not exist. You called the parameter anyMap but tried to access it as map, fix that and your code will compile aside from some rawtypes warnings

提交回复
热议问题