Creating a map in Java, parameter error

99封情书 提交于 2019-12-29 09:20:06

问题


I currently have this piece of code:

Map<Double, Character> memory = new HashMap<Double, Character>();

However it returns this error upon compiling:

GameLogic.java:5: type Map does not take parameters
Map<Double, Character> memory = new HashMap<Double, Character>();
   ^
1 error

I have no idea why its doing this as I see no reason it should after looking at other questions. It is within the 'GameLogic' class. Please could someone help.


回答1:


Two possible mistakes:

  • You are using JKD 1.4
  • You imported something else than java.util.Map



回答2:


You may have imported the wrong Map class. java.util.Map takes parameters.



来源:https://stackoverflow.com/questions/21977204/creating-a-map-in-java-parameter-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!