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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With