/*
将map集合中的映射关系存入到了set集合中,而这个关系的数据类型是:Map.Entry
*/
import java.util.*;
class Demo
{
public static void main(String[] args)
{
Map<String,String> it= new HashMap<String,String>();
it.put("01","java1");
it.put("02","java2");
it.put("03","java3");
it.put("04","java4");
it.put("05","java5");
Set<Map.Entry<String,String>> entryset = it.entrySet();
Iterator<Map.Entry<String,String>> al=entryset.iterator();
while(al.hasNext())
{
Map.Entry<String,String> me=al.next();
String key=me.getKey();
String value=me.getValue();
sop(key+":"+value);
}
}
public static void sop(Object obj)
{
System.out.println(obj);
}
}
|
|