title: Add element to a private Arraylist in Java
body: <p>I'm having trouble adding a new element to a ArrayList from another class.</p>
  
  <p>This class is where the ArrayList is:</p>
  
  <pre><code>public class Registry {
      private ArrayList&lt;Integer&gt; nums = new ArrayList&lt;Integer&gt;();
      public void addNum(int num) {
          this.nums.add(num);
      }
  }
  </code></pre>
  
  <p>But when I call from another class, like this:</p>
  
  <pre><code>Registry reg = new Registry();
  reg.addNum(1);
  </code></pre>
  
  <p>It doesn't add the <code>num</code> to the reg.nums..</p>