Skip to content

Commit af5de57

Browse files
committed
Example of Scala collection to Java 8 Stream from within Java.
Also added a unit test to make sure the example compiles.
1 parent bea1d39 commit af5de57

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (C) 2016 Typesafe Inc. <http://www.typesafe.com>
3+
*/
4+
5+
import org.junit.Test;
6+
7+
import scala.collection.mutable.ArrayBuffer;
8+
import scala.compat.java8.ScalaStreaming;
9+
10+
11+
public class StreamConvertersExampleTest {
12+
@Test
13+
public void MakeAndUseArrayBuffer() {
14+
ArrayBuffer<String> ab = new ArrayBuffer<String>();
15+
ab.$plus$eq("salmon");
16+
ab.$plus$eq("herring");
17+
assert( ScalaStreaming.from(ab).mapToInt(x -> x.length()).sum() == 13 );
18+
}
19+
}
20+

0 commit comments

Comments
 (0)