Thursday, 24 January 2019

Groovy: List: join: Join the string using given separator


public String join(String separator)
Join the elements of the list using given separator. It uses toString mehtod of the elements while joining.

HelloWorld.groovy
data = [2, 3, "Krishna", "5", "Hello World"]

result = data.join("****")

println "result : $result"

Output
result : 2****3****Krishna****5****Hello World


Previous                                                 Next                                                 Home

No comments:

Post a Comment