In Groovy, we can concatenate two arrays using the "+" operator. This creates a new array that contains the elements of the first array followed by the elements of the second array. Here is an example:
def arr1 = [1, 2, 3]
def arr2 = [4, 5, 6]
def concatenated = arr1 + arr2
In this example, we have two arrays: arr1 and arr2. We use the "+" operator to concatenate them into a new array called concatenated. The resulting array will contain the elements 1, 2, 3, 4, 5, and 6.
Another example with string arrays:
def arr1 = ["Hello", "world"]
def arr2 = ["Groovy", "is", "fun"]
def concatenated = arr1 + arr2
In this example, we have two arrays of strings (arr1 and arr2) which we concatenate using the "+" operator into a new array called concatenated. The resulting array will contain the strings "Hello", "world", "Groovy", "is", and "fun".