import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
public class MapTest {
/*
* 研究遍历一个Map
*/
public static void main(String[] args){
Map<String,String> m=new HashMap<String,String>();
m.put("a","1");
m.put("b","2");
m.put("c","3");
m.put("d","4");
// System.out.println(m.values());
// System.out.println(m.containsValue("1"));
// System.out.println(m.get("a"));//获取
//遍历Map
Set n=m.keySet();
Iterator it=n.iterator();
while(it.hasNext()){
//System.out.println(it.next().toString());
System.out.println(m.get(it.next().toString()));
}
}
}
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
public class MapTest {
/*
* 研究遍历一个Map
*/
public static void main(String[] args){
Map<String,String> m=new HashMap<String,String>();
m.put("a","1");
m.put("b","2");
m.put("c","3");
m.put("d","4");
// System.out.println(m.values());
// System.out.println(m.containsValue("1"));
// System.out.println(m.get("a"));//获取
//遍历Map
Set n=m.keySet();
Iterator it=n.iterator();
while(it.hasNext()){
//System.out.println(it.next().toString());
System.out.println(m.get(it.next().toString()));
}
}
}