JDK1.5中遍历使用泛型参数的 Map
或用Iterator
Map<String,String > map = new HashMap < String,String>();
for(Map.Entry <String,String> entry : map.entrySet()){
System.out.println(entry.getKey() + "-->" + entry.getValue());
}
或用Iterator
public class MyMap{
public static void main(String[] args){
Map map = new HashMap();
map.put("1","2");
map.put("2","3");
Set set = map.entrySet();
Iterator i = set.Iterator();
while(i.hasNext){
System.out.println(i.next);
}
}
}