How to convert a java Map to immutable Scala map via java code?

Viewed 2188

I need to create a immutable Scala map with java code. I have found other things on here about this but nothing that is updated to the current version.

I've tried:

public static <A, B> Map<A, B> toScalaMap(HashMap<A, B> m) {
        return JavaConverters.mapAsScalaMapConverter(m).asScala().toMap(
                Predef.<Tuple2<A, B>>conforms()
        );
}
3 Answers
Related