我正在用两个板创建一个游戏: http://imgur.com/nrCX5Ux
我想将“A”链接到“.”。两者都是字符串数组。 我想用这个:
indexesOfBoard.put("A", ((morris.START[0].charAt(0))));
但随后我收到如下错误:
The method put(String, String) in the type HashMap<String,String> is not applicable for the arguments (String, char)
如果我将 HashMap 更改为 < String, char>
我会得到:
Syntax error on token "char", Dimensions expected after this token
最佳答案
类型参数不能是原始类型。改用包装类替代方案:
HashMap<String, Character>
关于java - 这可能吗? : HashMap<String, 字符>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21020107/