Set set = map.keySet(); Iterator it = set.iterator(); for(;it.hasNext();) { System.out.println(map.get(it.next())); }
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); } } } 一楼的可以..我这种方法也行
System.out.println(entry.getKey() + " --> " + entry.getValue());
}
鉴于你给的报酬,我给出的答案是:使用Iterator,hoho :)
Iterator it = set.iterator();
for(;it.hasNext();) {
System.out.println(map.get(it.next()));
}
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);
}
}
}
一楼的可以..我这种方法也行