我最初从普通的LinkedHashMap开始

def person = [fname: "John", sname: "Wood", age: 23, job: "developer"]

然后,我像def personChanged = person.entrySet().toList()[(1..-1)]一样切片了此地图,该地图返回LinkedHashMap $ Entries的ArrayList。

现在,我正在努力将此Arraylist personChanged转换为其原始类型(LinkedHashMap)。类似于def personChanged = [sname: "Wood", age: 23, job: "developer"]

我希望我有道理,请任何人帮助我。

谢谢

最佳答案

也许这个吗?

def personChanged = [:]
person.entrySet().toList()[1..-1].each { personChanged[it.key] = it.value }

关于java - 如何将hashmap $ entry的ArrayList转换为hashmap,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57428138/

10-10 01:27