【问题标题】:Java hashmap issue [duplicate]Java哈希图问题[重复]
【发布时间】:2016-05-15 22:27:40
【问题描述】:

任何想法为什么下面的行有相关的错误消息?谢谢。

代码

Map<int,boolean> buffer = new HashMap<int, boolean>();

错误信息

Description Resource    Path    Location    Type
Syntax error, insert "Dimensions" to complete ReferenceType

【问题讨论】:

  • 您不能在地图中使用原始类型

标签: java hashmap


【解决方案1】:

你的代码应该是这样的:

Map<Integer,Boolean> buffer = new HashMap<Integer, Boolean>();

你不能使用泛型的原始类型。

您需要为它们使用 Wrapper 类。

【讨论】:

  • 感谢普里塔姆和亚辛!投票并将您的回复标记为答案。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-12-21
  • 2013-04-21
  • 1970-01-01
  • 2014-04-01
  • 1970-01-01
  • 2014-02-01
  • 1970-01-01
相关资源
最近更新 更多