Casting java.util.LinkedHashMap to scala.collection.mutable.Map -
import scala.collection.javaconversions._ val m = new java.util.linkedhashmap[string,int] val s: scala.collection.mutable.map[string,int] = m.asinstanceof[scala.collection.mutable.map[string,int]]
returns following error
java.lang.classcastexception: java.util.linkedhashmap cannot cast scala.collection.mutable.map
what wrong here , how casting? tried scala.collection.javaconverters._ getting same error.
importing javaconversions stuff doesn't make java's collection types instaces of scala collection types, provides handy conversion methods between 2 distinct collection hierarchies. in case, given import in question, can mutable scala map java linkedhashmap line:
val s = mapasscalamap(m)
Comments
Post a Comment