1.定义
HashMap<String,String> hashMap = new HashMap<>();
<String,String>只需要写一遍
2.获取key和value
//get a key/value set hashMap.keySet(); hashMap.values(); //judge whether contains key/value hashMap.containsKey("key"); hashMap.containsValue("value");
3.遍历
//loop for(Map.Entry<String, String> item: hashMap.entrySet()) { item.getKey(); item.getValue(); }