title: Cannot cast java ArrayList to scala immutable List
body: <p>I have the following data structure:</p>
  
  <blockquote>
    <p>java.util.Map[List[String],List[String]] = {[10, 20]=[1500], [5, 7]=[1400]}</p>
  </blockquote>
  
  <p>I am trying to extract the numbers <code>10 20 5 and 7</code> using Scala. The way I was looking to achieve this is:</p>
  
  <pre><code>map.head._1 -&gt; to extract 10 (map.head returns a tuple)
  map.head._2 -&gt; to extract 20 (map.head returns a tuple)
  </code></pre>
  
  <p>However, I am getting the following exception: </p>
  
  <pre><code>java.lang.ClassCastException: java.util.ArrayList cannot be cast to scala.collection.immutable.List
  </code></pre>
  
  <p>I have read about importing <code>import scala.collection.JavaConversions._</code> however, this did not fix anything.</p>
  
  <p>Thanks, any help is highly appreciated!</p>
  
  <p>The piece of code that tries to achieve this is: </p>
  
  <pre><code> def getTokenRangeForKeys(params: String): java.util.Map[List[String], List[String]] = {
      invokeOperation[java.util.Map[List[String], List[String]]]("XXX", "YYY", Array(params))
    }
  </code></pre>
  
  <p>The above method returns my map, which looks like this: </p>
  
  <pre><code>  map = java.util.Map[List[String],List[String]] = {[10, 20]=[1500], [5, 7]=[1400]}
  </code></pre>
  
  <p>What I have tried so far: </p>
  
  <pre><code>map.head._1 -&gt; java.lang.ClassCastException: java.util.ArrayList cannot be cast to scala.collection.immutable.List
  
  scalaMap = map.asScala
  m.headOption match {
    case Some((h1, h2)) =&gt; println((h1, h2)) -&gt; java.util.ArrayList cannot be cast to scala.collection.immutable.List
    case None =&gt; ...
  }
  </code></pre>