import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class Test {
public static void main(String[] args) {
Map userMap=new HashMap();
userMap.put("Tom", "boy");
userMap.put("Mary", "girl");
String sex=(String) userMap.get("Tom");
System.out.println(sex);
Iterator iter=userMap.keySet().iterator();
while(iter.hasNext()){
Object key=iter.next();
Object val=userMap.get(key);
System.out.println((String)key);
System.out.println((String)val);
}
}
}
JAVA 8 Map的使用
最新推荐文章于 2024-08-28 23:01:36 发布