title: Casting BasicDBList to Java Arraylist
body: <p>I am having a difficulty. I have retrieved a BasicDBList from database but now I want to iterate over the list but I cannot do it in it's BasicDBList format. So I want to ask that how can we cast BasicDBList to ArrayList of Java. Here is what I have tried.</p>
  
  <pre><code>DBCursor cursor1 = coll2.find();
  DBObject main1 = cursor1.next();
  ArrayList&lt;String[]&gt; ans = new ArrayList&lt;String[]&gt;();
  ans.add(((String[]) main1.get("Data")));
  </code></pre>
  
  <p>but I am having following error</p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.ClassCastException: com.mongodb.BasicDBList cannot be cast to [Ljava.lang.String;</p>
  </blockquote>