groovy append to string
Groovy: Append to String
To append a string in Groovy, you can use the +
operator or the +=
operator. Here's an example:
def str = "Hello"
str += " World"
println(str) // Output: Hello World
Alternatively, you can use the concat()
method to append a string:
def str = "Hello"
str = str.concat(" World")
println(str) // Output: Hello World
These methods allow you to concatenate or append strings in Groovy.