title: Cannot resolve symbol "add" while adding class object to an ArrayList
body: <p>I am working on a class for an Address Book Application on Java called &quot;AddressBook.java&quot;, which I have written the following code:</p>
  <pre><code>package com.company;
  import java.util.ArrayList;
  
  class AddressBook {
      ArrayList&lt;AddressEntry&gt; addressEntryList = new ArrayList&lt;AddressEntry&gt;();
      AddressEntry test = new AddressEntry(&quot;john&quot;, &quot;doe&quot;, &quot;yes&quot;, &quot;no&quot;, &quot;maybe&quot;, 1, &quot;I guess&quot;, &quot;ok&quot;);
      
      addressEntryList.add(test);
  }
  </code></pre>
  <p>Since I was just testing the test object, I had to give random values for the variables from my AddressEntry class and it seemed to work well. However, when I ran it in IntelliJ, I received the error</p>
  <pre><code>Cannot resolve symbol 'add'
  </code></pre>
  <p>This made the adding method not working.</p>