Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using scala map in Java

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.

I am a newbie to scala and java. How can I convert that scala map to java dicionary?

like image 619
K.K Avatar asked Feb 01 '14 06:02

K.K


1 Answers

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

java.util.Map<String, String> javaMap = scala.collection.JavaConverters
                                           .mapAsJavaMapConverter(scalaMap).asJava();
like image 195
maestr0 Avatar answered Oct 10 '22 21:10

maestr0