title: Compare content of the ArrayList against Resultset
body: <p>I have String ArrayList to compare against Resultset. </p>
  
  <p>Ex: ArrayList Elements</p>
  
  <pre><code>ITM001
  ITM002
  ITM003
  ITM004
  </code></pre>
  
  <p>Ex: Resultset 1</p>
  
  <pre><code>ITM001
  ITM002
  ITM003
  ITM004  
  </code></pre>
  
  <p>Contains all elements<br>
  return ArrayList Empty;</p>
  
  <p>Ex: Resultset 2</p>
  
  <pre><code>ITM001
  ITM002
  ITM004  
  </code></pre>
  
  <p>Missing ITM003<br>
  return ArrayList ITM003;</p>
  
  <p>Ex: Resultset 3</p>
  
  <pre><code>ITM001
  ITM002 
  </code></pre>
  
  <p>Missing ITM003, ITM004<br>
  return ArrayList ITM003,ITM004;</p>
  
  <blockquote>
    <p>If Resultset does not contain all elements of Arraylist, those missing
    elements must return as an ArrayList. Else return empty ArrayList.</p>
  </blockquote>
  
  <p>This is what I tried.</p>
  
  <pre><code>public static ArrayList&lt;String&gt; checkStoreItems(String currentStore, ArrayList&lt;String&gt; stlist) throws ClassNotFoundException, SQLException {
          Connection conn = DBConnection.conn();
          String sql = "select itemId from Store_Items where storeID=(select storeID from StoreMain where locationName=?)";
          Object []values ={currentStore}; 
          ResultSet res = DBHandller.getData(sql, conn, values);
          ArrayList&lt;String&gt; storelist = new ArrayList&lt;String&gt;();
          while(res.next()){
                String item = res.getString("itemId");
                for (int i = 0; i &lt; stlist.size(); i++) {
                      if (item.contains(stlist.get(i))) {
                            continue;     
                      }else{
                            storelist.add(item);
                      }
                }
  
          }
  
          return null;
  
    }
  </code></pre>