Mic*_*nes 1 java dictionary hashmap
这是我用Java编写的第二天编码,不用担心我不是新编码.无论如何,我不习惯没有像Python这样的字典,它可以存储Key和Value.
那是我遇到Java HashMaps的时候.目前,我似乎无法让他们工作,我不确定为什么.这是我正在使用的代码,但这些似乎引发了错误:
Map<String, String> visual = new HashMap<String, String>();
Run Code Online (Sandbox Code Playgroud)
然后这是它产生的错误:
Multiple markers at this line
- The type Map is not generic; it cannot be parameterized with arguments <String, String>
- HashMap cannot be resolved to a type
Run Code Online (Sandbox Code Playgroud)
我甚至导入哈希库:
import java.util.Map;
import java.util.HashMap;
Run Code Online (Sandbox Code Playgroud)
所以我的问题就是,为什么HashMap不起作用?谢谢!:)
PS这是我的一小段代码:
public Map areaTotal() {
Map<String, String> visual = new HashMap<String, String>();
return visual;
}
Run Code Online (Sandbox Code Playgroud)
编辑
对不起,我想我确实忘了包含其他一些信息.