- import java.util.*;
- public class MapDemo2
- {
- public static void main(String[] args)
- {
- Map<String,String> map=new HashMap<String,String>();
- map.put("1", "zhangsan1");
- map.put("2", "zhangsan2");
- map.put("3", "zhangsan3");
- map.put("4", "zhangsan4");
- 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.println(key+"---"+value);
-
- }
- }
- }
复制代码 位置:16天05Map--entrySet。在*****处entryset.iterator()调用迭代器,entryset应该是指向Set接口的实现子类吧?调用的具体是Set接口的哪个实现子类的呢?
|
|