Using scala map in Java

前端 未结 2 1324
长发绾君心
长发绾君心 2021-01-14 02:07

I have two files. One is scala and other is java.

Scala file has a function which returns scala immutable map.

Java file wants to use that map as dictionary.

2条回答
  •  一生所求
    2021-01-14 03:06

    This is a better way to convert a Scala immutable.Map to a Java Map in Java.

    java.util.Map javaMap = scala.collection.JavaConverters
                                               .mapAsJavaMapConverter(scalaMap).asJava();
    

提交回复
热议问题