Map对象的keySet()方法

对于一个Map对象,可以通过对应的keySet()方法获得一个包含Map所有key值的Set对象;

例子:
 Map<String ,String> map = new HashMap<String ,String>();

map.put("_id","001");

map.put("_name","张三");

map.put("_age","23");

String str="";

for(String s: map.keySet()){

str+=s+" 空格 ";

}

System.out.println(str);

 

打印:

001 空格 张三 空格23

posted on 2012-09-24 19:13  swp123  阅读(968)  评论(0编辑  收藏  举报