Tutorial by Examples

When you need to pass a collection into a Java method: import scala.collection.JavaConverters._ val scalaList = List(1, 2, 3) JavaLibrary.process(scalaList.asJava) If the Java code returns a Java collection, you can turn it into a Scala collection in a similar manner: import scala.collectio...
Arrays are regular JVM arrays with a twist that they are treated as invariant and have special constructors and implicit conversions. Construct them without the new keyword. val a = Array("element") Now a has type Array[String]. val acs: Array[CharSequence] = a //Error: type misma...
Scala offers implicit conversions between all the major collection types in the JavaConverters object. The following type conversions are bidirectional. Scala TypeJava TypeIteratorjava.util.IteratorIteratorjava.util.EnumerationIteratorjava.util.IterableIteratorjava.util.Collectionmutable.Bufferjav...
A Java 8 compatibility kit for Scala. Most examples are copied from Readme Converters between scala.FunctionN and java.util.function import java.util.function._ import scala.compat.java8.FunctionConverters._ val foo: Int => Boolean = i => i > 7 def testBig(ip: IntPredicate) = ip.tes...

Page 1 of 1