I have a Scala function f(s1: String, s2: String): Map[String,String]
I want to allow a colleague coding in Java to call a Java method I'm writing:
HashMap<String, String> f(String s1, String s2)
This calls my Scala function. What I've found, on the Java side, is that Scala has returned a scala.collection.immutable.Map
.
How do I make a Java HashMap out of it? Or should I be doing something else?
I think what you are looking for is here. Specifically the mapAsJavaMap
method.
Where the preferred usage is explained in this SO question Using imported implicits
and asJava