Friday 10 August 2018

Can I use a Stream multiple times?

Just a quick question, that I answered using a small unit test.

Stream<String> stream = Arrays.asList("John""Paul""Ringo""George").stream();
assertThat(stream.filter(x -> x.equals("Matthias")).collect(Collectors.toList())).hasSize(0);
assertThat(stream.count()).isEqualTo(4);

Does this work?

Answer in my next blog.

No comments:

Post a Comment