title: how to store array in mongodb?
body: <p>I want to store a simple array of latitude,longitude inside a mongoDB collection using java and I am using following code but my "loc" array always is empty :</p>
  
  <pre><code>BasicDBObject doc = new BasicDBObject();
  //doc.put("key " , r.getKey());
  doc.put("category" , r.getKey());
  doc.put("type" , r.getValue());
  
  BasicDBObject latlon = new BasicDBObject();
  
  
  ArrayList&lt;Float&gt; aLatLong = new ArrayList&lt;Float&gt;();
  
  {
  
  
  
  
      Float fLat = Float.parseFloat(r.getLatitude());
      Float fLon = Float.parseFloat(r.getLongitude());
      aLatLong.add(fLat);
      aLatLong.add(fLon);
  
      latlon.put("lat" , fLat);
      latlon.put("lon" , fLon);
  }
  
  
  doc.put( "loc" , aLatLong);
  </code></pre>
  
  <p>but when I don't use ArrayList at all and try to store latlon into "loc" it will show me the data but its not an array anymore.</p>
  
  <p>how can I save a simple array in mongoDB?</p>