Tuesday, 22 April 2014

I like Java 8 streams

I'm learning the JDK 8 API.
This seems pretty sweet, for Java standards:

Stream<String> input = Stream.of("Tick", "Trick", "Track");
Map output = input.collect(toMap(t -> t.length(), t -> t, (t, t2) -> t + "," + t2));
System.out.println(output);

Result{4=Tick, 5=Trick,Track}