Convert it to:
def getStrings() : Seq[String] = {
val results : java.util.List[String] = new java.util.ArrayList[String]()
results
}
This is because, the implicit function for the conversion is defined as:
implicit def asScalaBuffer[A](l: java.util.List[A]): mutable.Buffer[A]
It returns a mutable.Buffer
and not scala.collection.immutable.List
. Hence the error. So alternative is to use a Seq
instead of List
or convert it to a immutable.List
as below:
def getStrings() : List[String] = {
val results = new java.util.ArrayList[String]()
results.toList
}