title: How to convert scala.collection.immutable.HashMap to java.util.Map in spark dataset 2.2 in java
body: <p>I have a dataset,say DS. </p>
  
  <pre><code>DS.printSchema()
  
  root
   |-- BRAND: string (nullable = true) 
   |-- single: map (nullable = true)
   |    |-- key: string
   |    |-- value: string (valueContainsNull = true) 
   |-- PRICE: string (nullable = true)
  </code></pre>
  
  <p>When I tried to iterate DS using map transformation and access single map variable it is throwing Below Error.</p>
  
  <pre><code>    DS.map(row -&gt; {
  
      Map&lt;String, String&gt; singleColMap = row.getAs("single");
  
      })
  
  Error - 
      java.lang.ClassCastException: scala.collection.immutable.HashMap$HashTrieMap cannot be cast to java.util.Map
  </code></pre>
  
  <p>Can someone help one on how to access map variable in spark java.</p>
  
  <p>Thanks!.</p>