def sample = ['Groovy', 'Gradle', 'Grails', 'Spock'] as String[]
def result = sample.stream() // Use stream() on array objects
.filter { s -> s.startsWith('Gr') }
.map { s -> s.toUpperCase() }
.toList() // toList() added to Stream by Groovy
If you really want to create an array rather than a list use either
String[] names = ["lucas", "Fred", "Mary"]
or
def names = ["lucas", "Fred", "Mary"].toArray()