Convert Java Map to Scala Map

后端 未结 4 1760
傲寒
傲寒 2020-12-02 18:38

I have a java map: java.util.Map> and I would like to convert it to the scala map: Map[SomeObjec

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-02 19:09

    You can convert the Java Map into Scala Map using the below function:

    val scalaMap = javaMap.asScala;
    

    For using this you need to import the import scala.collection.JavaConverters._ library.

    Hope this helps.

提交回复
热议问题