How do I convert a Groovy String collection to a Java String Array?

前端 未结 1 1774
情歌与酒
情歌与酒 2021-02-04 23:47

I\'m trying to call a methond on a Java class from a Groovy class. The Java method has a String array as a parameter, and I have a collection of Strings in my Groovy class. Ho

1条回答
  •  死守一世寂寞
    2021-02-05 00:17

    To be correct, def data = ["a","b","c"] it is a List, not an array.

    Just try casting like this:

    def data = ["a","b","c"] as String[]
    

    0 讨论(0)
提交回复
热议问题