通过Map.Entry(String,String) 获取,然后使用entry.getKey()获取到键,通过entry.getValue()获取到值
Map<String,String> map = new HashMap<>();
for(Map.Entry<String, String> entry : map.entrySet()){
System.out.println(“键 key :”+entry.getKey()+" 值value :"+entry.getValue());
}