Skip to content

Instantly share code, notes, and snippets.

@dlhartveld
Last active December 14, 2015 08:29
Show Gist options
  • Save dlhartveld/5057913 to your computer and use it in GitHub Desktop.
Save dlhartveld/5057913 to your computer and use it in GitHub Desktop.
Example usage of the Stream API from JDK8.
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