public static void main(String[] args) {
Map map=new HashMap();
map.put("name", "姓名");
map.put("sex", "性别");
map.put("age", "年龄");
map.put("address", "地址");
System.out.println(map.size());
Set set=map.keySet();
System.out.println(set);
Iterator iterator2=map.keySet().iterator();//取得key值set集合
while(iterator2.hasNext()){//通过迭代器输出
System.out.println(iterator2.next());
}
}
怎么得到Map的key值集合
最新推荐文章于 2023-11-17 17:18:54 发布