Created
May 3, 2020 01:18
-
-
Save diegopacheco/8d5c3ea0e2e82acdcc5d3fb3ab2d7e23 to your computer and use it in GitHub Desktop.
Java Simple Stream
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<String> rawValues = Arrays.asList(new String[] { "Peter","Adam", "Allan","Anna","John","Paul","Peter" }); | |
List<String> people = rawValues | |
.stream() | |
.distinct() | |
.sorted() | |
.filter( name -> name.startsWith("A")) | |
.map(String::toUpperCase) | |
.limit(2) | |
.collect(Collectors.toList()); | |
System.out.println("first 2 People who started with A: " + people); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment