keySet和entrySet两种
-
- 1.Set<String> s=m.keySet();
- for(Iterator<String> it=s.iterator();it.hasNext();){
- String key=it.next();
- String value=m.get(key);
- System.out.println(key+"---"+value);
- }
- 2.Set st=m.entrySet();
- for(Iterator in=st.iterator();in.hasNext();){
- System.out.println(in.next());
- }
复制代码
keySet是分别取出key值和value值,entrySet是取出一组key和value |