title: Checking if there is a certain string in an object contained in an ArrayList, then adding the object to another ArrayList
body: <p>I have <code>Arraylist</code> of objects <code>ArrayList&lt;Product&gt; productDatabase.</code> The object contains a <code>String</code> and a <code>double</code> and then these objects will be added to the productDatabase by <code>addProductToDatabase();</code> as follows:</p>
  
  <pre><code>public void addProductToDatabase(String productName, double dimensions); {
      Product newProduct = new Product(ProductName, dimensions);
      productDatabase.add(newProduct);
  }
  </code></pre>
  
  <p>I also want to make an <code>Arraylist&lt;ProductCount&gt; productInventory</code> which counts how many <code>Product</code> are accounted for. Before it can add to <code>ArrayList&lt;ProductCount&gt; productInventory</code> however, it should first check if the object details exist in the productDatabase while running <code>addProductToInventory()</code></p>
  
  <pre><code>public Product getProduct(String name) {
      for(i = 0; i &lt; productDatabase.size(); i++)
      if(productDatabase.get(i).contains(name) //Error: cannot find symbol- method contains.(java.lang.String)
          return productDatabase.get(i)
  }
  
  public void addProductToInventory(String productName, double quantity)
  {
      Product p = getProduct(name);        
      productCount.add(new ProductCount(o, quantity)); 
  }
  </code></pre>
  
  <p>Assume that you always have different objects (so nothing will have the same name), but you're always unsure of the dimensions (so when you input the same <code>producttName</code> + dimensions you edit the dimensions in it).</p>
  
  <p>At the end of the day, you have to put all the items in it a large box and report what you've inventoried, so you also have a <code>getProductQuantityTotal()</code> and you have to <code>getProductDimensionTotal()</code>-- as the name suggests, get the total of number of objects you've counted, and the sum of the dimensions.</p>
  
  <p>What do I have to add/change/remove about this code? Don't consider syntax first (because BlueJ checks for common syntax errors and I just typed this by hand). I'm sure that I'm missing a <code>for</code> statement somewhere, and I'm probably misusing <code>contains()</code> because it won't recognise it (I have <code>import java.util.*;</code> and <code>import java.util.ArrayList;</code>)</p>