title: Converting DBObject to Java Object while retrieve values from MongoDB
body: <p>From my Java application, I have stored the values in mongoDB in ArrayList(set of Java objects). 
  How can I retrieve the data from DBObject</p>
  
  <p>I am storing the data in mongoDB like this:</p>
  
  <pre><code>{  "students" : [{"firstName" : "Jesse", "lastName" : "Varnell", "age" : "15", "gender" : "M" }, { "firstName" : "John", "lastName" : "Doe", "age" : "13", "gender" : "F"}] }
  </code></pre>
  
  <p>I am having the Java Object for the Student like:</p>
  
  <pre><code>public class Student {
      public String firstName;
      public String lastName;
      public String age;
      public String gender;  // M, F      
  }
  </code></pre>
  
  <p>I am retrieving the data from mongoDB like:</p>
  
  <pre><code>BasicDBObject query = new BasicDBObject();
  query.put("user", username); 
  DBCursor cursor = theCollection.find(query); 
  while (cursor.hasNext()) {
      DBObject theObj = cursor.next();
      //How to get the DBObject value to ArrayList of Java Object?
  }
  </code></pre>