title: Having issues with List in Java
body: <p>I have this class:</p>
  
  <pre><code>public class Attributes {
  
  
      List text = new ArrayList();
  
      List angle = new ArrayList();
  
      public Attributes() {
  
      }
  
      public int getHowManyNodes() {
  
          int howMany = 0;
  
          howMany += text.isEmpty() ? 0 : text.size();
          howMany += angle.isEmpty() ? 0 : angle.size();
  
          return howMany;
      }
  
  }
  </code></pre>
  
  <p>And when I do:</p>
  
  <pre><code>Attributes attributes = new Attributes();
  System.out.print(attributes.getHowManyNodes());
  </code></pre>
  
  <p>It gives <strong>Exception in thread "main" java.lang.NullPointerException</strong></p>
  
  <p>Weirdly tho, it only gives an error on <em>"angle.isEmpty()"</em> not on <em>"text.isEmpty()"</em></p>
  
  <p>Why does it say it is null when I initialize it with:</p>
  
  <pre><code>List angle = new ArrayList();
  </code></pre>
  
  <p><strong>Edit1:</strong> </p>
  
  <pre><code>Full error:
  
  Exception in thread "main" java.lang.NullPointerException
      at projectmerger1.Attributes.getHowManyNodes(Attributes.java:55)
      at projectmerger1.Project.listGameVariables(Project.java:235)
      at projectmerger1.ProjectMerger1.main(ProjectMerger1.java:289)
  Java Result: 1
  </code></pre>
  
  <p>Minor edit:</p>
  
  <p>Line 55 in Attributes Class is</p>
  
  <p><code>howMany += angle.isEmpty() ? 0 : angle.size();</code></p>
  
  <p><strong>Edit2:</strong></p>
  
  <pre><code>    public class Project {
  
          Game game;
  
          public void listGameVariables() {
  
              System.out.print(game.attributes.getHowManyNodes());
  
          }
  
  }
  
  public class Game {
  
      Attributes attributes = new Attributes();
  }
  </code></pre>
  
  <p>This is my whole setup.</p>