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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -