Map
Map初始化
Map<String, String> map =
new
HashMap<String, String>();
添加数据
map.put(
"key1"
,
"value1"
);
删除数据
map.remove(
"key1"
);
获取数据
map.get(
"key1"
);
清空map
map.clear();
使用keySet()遍历
for
(String key : map.keySet()) {
System.out.println(key +
" :"
+ map.get(key));
}
使用entrySet()遍历
for
(Map.Entry<String, String> entry : map.entrySet()) {
System.out.println(entry.getKey() +
" :"
+ entry.getValue());
}