title: Creating an ArrayList and adding items
body: <p>Im learning Java and having a problem with ArrayList.</p>
  
  <p>Firstly I have a class called Item, with which I create various item objects.
  Then I have a class Catalogue which is an array list and should hold a list of the item objects I create.
  At the moment I can manually add the items to the catalogue by invoking an addItem method on the Catalogue object and manually entering the name of the item object I want to add (item1 item2 item3 etc)
  But I wanted to know if there is a way to add the items to the ArrayList automatically each time I create an item object?</p>
  
  <p>I should mention, my list needs to hold an infinite amount of items, so I have not specified a size in my code.
  Any help would be greatly appreciated :)
  Thanks</p>
  
  <pre><code>import java.util.ArrayList;
  
  public class Catalogue
  {
     private ArrayList&lt;Item&gt; catalogue;
  
      public Catalogue ()
      { 
        catalogue = new ArrayList&lt;Item&gt;();
      }
  
  
      public void addAnItem(Item item)
      {
        catalogue.add(item);
      }
  }
  </code></pre>