title: Cannot reference a variable - cannot find symbol
body: <p>I'm making an ArrayList of a type 'Item' that I've created. The class has a variable called <code>name</code> to describe the item. The items are stored in an ArrayList.</p>
  <p>I cannot figure out how to reference the <code>name</code> variable because it is producing an error in the compiler that says <code>cannot find symbol - variable name.</code> Specifically, I reference it like this:</p>
  <pre><code>for (int i=0; i &lt; theMenu.size(); i++) {
                  Item temp = theMenu.get(i);
                  if(temp.name == keyword)
                      System.out.println(&quot;test&quot;);
              }
  </code></pre>
  <p>I've also tried referencing it like this:</p>
  <pre><code>for (int i=0; i &lt; theMenu.size(); i++) {
                  if(theMenu.get(i).name == keyword)
                      System.out.println(&quot;test&quot;);
              }
  </code></pre>
  <p>It produces the same error. Please help! Here is the relevant code:</p>
  <pre><code>import java.util.ArrayList;
  import java.util.Scanner;
  
  public class Doms {
  
      public static class Item {
          public Item(int itemID, String itemName, double itemPrice, double itemSalePrice, String itemSaleBeginDate, String itemSaleEndDate, ArrayList&lt;Integer&gt; itemReviews, ArrayList&lt;String&gt; itemComments) {
              int id = itemID;
              String name = itemName;
              double price = itemPrice;
              double salePrice = itemSalePrice;
              String SaleBeginDate = itemSaleBeginDate;
              String SaleEndDate = itemSaleEndDate;
              ArrayList&lt;Integer&gt; reviews = itemReviews;
              ArrayList&lt;String&gt; comments = itemComments;
          }
      }
  
      public static void main(String[] args) {
  
          // A list containing each Item and all of its contents
          ArrayList&lt;Item&gt; items = new ArrayList&lt;Item&gt;();
  
          // Create Item elements
          ArrayList&lt;Integer&gt; reviews2 = new ArrayList&lt;Integer&gt;();
          ArrayList&lt;String&gt; comments2 = new ArrayList&lt;String&gt;();
          Item item2 = new Item(2, &quot;Sour Cream Donut&quot;, 1.29, 1.29, &quot;&quot;, &quot;&quot;, reviews2, comments2);
          items.add(item2);
  
          //This part doesn't work
          for (int i=0; i &lt; theMenu.size(); i++) {
              Item temp = theMenu.get(i);
              if(temp.name == keyword)
                  System.out.println(&quot;test&quot;);
          }
      }
  }
  </code></pre>