Map集合的遍历方法
作者:互联网
Map集合的遍历方法
package it.com.cc.five;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class MapTest {
public static void main(String[] args) {
Map<String,String> map=new HashMap<String,String>();
map.put("成功","失败");
map.put("贫穷","富贵");
map.put("勤奋","学习");
Set<Map.Entry<String,String>> entrySet= map.entrySet();
for (Map.Entry<String,String> me:entrySet){
String key=me.getKey();
String value = me.getValue();
System.out.println(key+","+value);`
}
}
}`
标签:Map,遍历,java,String,map,entrySet,put,集合 来源: https://blog.csdn.net/qq_43172333/article/details/119142051