title: How do you add to an ArrayList using generics?
body: <p>I'm struggling with an assignment of mine and I can't figure out how to add another element to my list. </p>
  
  <pre><code>import java.util.ArrayList;
  
  public class Ballot {
      private ArrayList&lt;Candidate&gt; ballot;
      private String officeName;
  
      public Ballot(String officeName) {
          this.officeName = officeName;
          ArrayList&lt;Candidate&gt; ballot = new ArrayList&lt;Candidate&gt;();
      }
  
      public String getOfficeName() {
          return officeName;
      }
  
      public void addCandidate(Candidate c) {
          ballot.add(c);
      }
  
      public ArrayList&lt;Candidate&gt; getCandidates() {
          return ballot;
      }
  
      public static void main(String[] args) {
          Ballot b = new Ballot("Election");
          b.addCandidate(new Candidate("Sarah", "President"));
          System.out.println(b);
      }
  }
  </code></pre>
  
  <p>When I try to run the document, it throws a <code>NullPointerException</code>. What am I doing wrong? </p>