I'm using a Java library from inside Scala 2.11 code. This Java library has a static load
method that returns a Map<String,String>
. Example usage in Java:
Map<String,String> map = Environment.load("dev");
I'm trying to get it working in Scala like so:
import scala.collection.JavaConverters._
val map : Map[String,String] = Environment.load("dev").asJava
And I'm getting a compiler error:
" Cannot resolve symbol asJava "
Any ideas?
Use asScala
instead of asJava
:
import scala.collection.JavaConverters._
val map: Map[String, String] = Environment.load("dev").asScala.toMap
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.