image.png
import java.util.*;
class MapDemo2
{
public static void main(String[] args)
{
Map<String,String> m = new HashMap<String,String>();
//添加元素
map.put("01",zhangsan1);
map.put("02",zhangsan2);
map.put("03",zhangsan3);
//将Map集合中的映射关系去除。存入到Set集合中。
Set<Map.Entry<String,String>> entrySet = map.entrySet();
Iterator<Map.Entry<String,String>> it = entrySet.iterator();
while(it.hasNext())
{
Map.Entry<String,String> me = it.next();
String key = me.getKey();
String value = me.getValue();
System.out.printlb(key+":"+value);
}
}
}
网友评论