title: How to insert a list of data in mongodb using java
body: <p>I have a list of integers and list names and I inserted this information in mongodb via console using following code</p>
  
  <pre><code>db.collection.insert({"_id":"integers","data":[1,2,3,4,5]})
  db.collection.insert({"_id":"names","data":["A","B","C","D"]})
  </code></pre>
  
  <p>the query <code>db.collection.find().pretty</code> gave the following result</p>
  
  <pre><code>{ "_id" : "ArrayList", "data" : [ 1, 2, 3, 4, 5, 6 ] }
  {
      "_id" : "Names",
      "data" : [
          "A",
          "B",
          "C",
          "D"
      ]
  }
  </code></pre>
  
  <p>How to do it in java?</p>