Java 8 Stream on Android
Nico Passo
1475

You write that Java 8 Streams and LSA work mostly in the same under the hood, but that’s not the case. LSA misses the point of Streaming APIs.

The following, simple example, will just throw an exception with LSA, while it’s perfectly legal in Java 8 (I’d say it’s at the core of any Streaming API to support lazy evaluation):

ArrayList<String> strings = new ArrayList<>(Arrays.asList("Foo", "Bar"));
com.annimon.stream.Stream<String> stream = com.annimon.stream.Stream.of(strings);
stream = stream.filter(s -> s.equals("Bar"));
strings.add("Bar");
long count = stream.count();
assertEquals(count, 2);

I hope someone comes up with a conforming re-implementation for Android, soon.

Like what you read? Give Matt a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.