scala.collection.JavaConversions will not help you with the scala.Boolean to java.lang.Boolean problem. However, the following will work: boolean2Boolean scala.Predef method:
val a = Map[Int, Boolean](1 -> true, 2 -> false) val b: java.util.Map[Int, java.lang.Boolean] = a.mapValues(boolean2Boolean)
Or you can use the Java constructor Boolean(boolean value) :
val a = Map[Int, Boolean](1 -> true, 2 -> false) val b: java.util.Map[Int, java.lang.Boolean] = a.mapValues(new java.lang.Boolean(_))
Or you can simply declare the first map to use the Java reference type:
val a = Map[Int, java.lang.Boolean](1 -> true, 2 -> false) val b: java.util.Map[Int, java.lang.Boolean] = a
Travis brown
source share