keySet()
returns only its keys, so this is a list Map<String, String>
. If you want to iterate through Map.Entry
, release .keySet()
:
for (Map.Entry<Map<String, String>, Map<String, String>> entry : firstMap) {
println "entry=$entry"
}
Other cycling options:
// iterate with two arguments
firstMap.each { Map<String, String> key, Map<String, String> value ->
println "key=$key, value=$value"
}
// iterate through entries
firstMap.each { Map.Entry<Map<String, String>, Map<String, String>> entry ->
println "entry=$entry"
}
// untyped
for (entry in firstMap) {
println entry
}
source
share