Groovy get the list of keys of a map as an ArrayList
examples/groovy/list_keys.groovy
def data = [ name : 'Foo Bar', age : 42, email : 'zoo@bor.com', ] println(data) my_keys = data.keySet() println(my_keys.getClass()) // class java.util.LinkedHashMap$LinkedKeySet our_keys = my_keys as ArrayList println(our_keys.getClass()) // class java.util.ArrayList println(our_keys)
If you only want to iterate over the map keys, you don't need to convert them into and ArrayList.
Published on 2019-08-24
If you have any comments or questions, feel free to post them on the source of this page in GitHub. Source on GitHub.
Comment on this post