Groovy web console

subscribe to the feed Subscribe
to this
site

Stream-2

Published 4 months ago by Amit with tags Stream-2
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
import java.util.stream.Collectors;
def sample = ['Groovy', 'Gradle', 'Grails', 'Spock'] as String[]
def result = Arrays.stream(sample )                     
        .filter { s -> s.startsWith('Gr') }                                     
        .map { s -> s.toUpperCase() }                                     
        .collect(Collectors.toList())