Last active
December 14, 2015 08:29
-
-
Save dlhartveld/5057913 to your computer and use it in GitHub Desktop.
Example usage of the Stream API from JDK8.
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> ss = new ArrayList<>(); | |
ss.add("x,y,z"); | |
ss.add("x.y.z"); | |
ss.add("a,b,c"); | |
ss.add("i,j,k"); | |
String result = ss.stream() | |
.map(s -> s.replace(",", ".")) | |
.filter(s -> !s.contains("b")) | |
.distinct() | |
.sorted() | |
.collect(Collectors.toStringJoiner(",")).toString(); | |
System.out.println("Result: " + result); | |
== Output == | |
Result: i.j.k,x.y.z |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment