title: How to $and two documents in mongodb and Java?
body: <p>I am using mongodb with Java 3.0 driver. I have a scenario where I have to perform logical and i.e, <code>$and</code> on my queries. For example, I have two documents already created and I am trying to do something like this:</p>
  
  <pre><code>iterable = mongoDatabase.getCollection("restaurants").find(
                                                new Document("$and", asList(abc,
                                                       updatedDocumentTypeOne)));
  </code></pre>
  
  <p>where <code>abc</code> is one document and <code>updatedDocumentTypeOne</code> is another document. I found this in mongodb manual but I am getting error as first create asList Method.</p>
  
  <p>Or how to replicate the following in Java: </p>
  
  <pre><code>db.inventory.find( {
      $and : [
          { $or : [ { price : 0.99 }, { price : 1.99 } ] },
          { $or : [ { sale : true }, { qty : { $lt : 20 } } ] }
      ]
  } )`
  </code></pre>