class GroovyTest {
static void main(args) {
def map = [1: 'a', 2: 'b', 3: 'c']
def entries = map.entrySet()
entries.each{ entry ->
println entry.key+"-"+entry.value
}
def keys = map.keySet()
println keys
def values = map.values()
println values
}
}
输出:
1-a
2-b
3-c
[1, 2, 3]
[a, b, c]
网友评论