开发者

How to separate List elements with commas in Groovy?

开发者 https://www.devze.com 2023-01-04 14:10 出处:网络
def names =开发者_C百科 [\"myname\", \"yourname\", \"theirname\", \"allnames\"] String n = \"\" names.each{
def names =开发者_C百科 ["myname", "yourname", "theirname", "allnames"]

String n = ""
names.each{
    n += it + ","
}

println n

Output:

myname,yourname,theirname,allnames,

How do I get rid of the trailing comma?


names.join(",")
0

精彩评论

暂无评论...
验证码 换一张
取 消