To implicitly converting Java collections to Scala you need to import the following.
Very handy when you use Java libraries from Scala.
import scala.collection.JavaConversions._
will do the implicit conversion from Java List<T> to Scala List[T].
var computerScientists = new java.util.ArrayList[String]("Linus", "Doug Cutting", "Jon Postel")
computerScientists.foreach(println)
foreach is a function on collections in Scala
Very handy when you use Java libraries from Scala.
import scala.collection.JavaConversions._
will do the implicit conversion from Java List<T> to Scala List[T].
var computerScientists = new java.util.ArrayList[String]("Linus", "Doug Cutting", "Jon Postel")
computerScientists.foreach(println)
foreach is a function on collections in Scala
No comments:
Post a Comment