title: Java Enum Causing NullPointerException
body: <p>I have an enum and I am trying to iterate through it using a foreach and for some reason it is returning null on my first constant. I see nothing wrong with it.</p>
  
  <p>First off, I am creating and initializing a hashmap to store the enums so that I can manipulate them to my heart's content.</p>
  
  <pre><code>public class ScriptLoader {
      private ResourceLocation resloc;
      private File file;
      private FileReader fr;
      private BufferedReader br;
      //Here
      private Map&lt;String, Node&gt; nodes;
  </code></pre>
  
  <p>Init here:</p>
  
  <pre><code> public void loadScript() throws IOException{
          file = resloc.getFile();
          fr = new FileReader(file);
          br = new BufferedReader(fr);
          //Here
          nodes = new HashMap&lt;&gt;();
          this.setNodes();
          if(Engine.stateOfEngine == EnumEngineState.DEBUGGER_ON) {
              Engine.LOGGER.log("\tScript Loaded!", EnumLoggerTypes.DEBUG);
          }
      }
  </code></pre>
  
  <p>Secondly, I am creating a method called <code>setNodes()</code> which will add the constants to the map in the parent class of <code>setNodes()</code> which is called <code>ScriptLoader</code>.</p>
  
  <pre><code>public void setNodes(){
          for(EnumNodes node : EnumNodes.values()) {
              nodes.put(node.getName(), node.getNode());
          }
      }
  </code></pre>
  
  <p>And I am calling it here:</p>
  
  <pre><code>public void loadScript() throws IOException{
          file = resloc.getFile();
          fr = new FileReader(file);
          br = new BufferedReader(fr);
          nodes = new HashMap&lt;&gt;();
          this.setNodes();
          if(Engine.stateOfEngine == EnumEngineState.DEBUGGER_ON) {
              Engine.LOGGER.log("\tScript Loaded!", EnumLoggerTypes.DEBUG);
          }
      }
  </code></pre>
  
  <p>Now, I have an <a href="https://github.com/AlexCouch/text-game-engine/blob/master/src/org/ggg/engine/consts/EnumNodes.java" rel="nofollow noreferrer">enum</a> that I have a list of "nodes" that I want to iterate through, which can be seen in the <code>setNodes()</code> method.</p>
  
  <p>Now the crash report is <a href="https://pastebin.com/Y83czLPX" rel="nofollow noreferrer">here</a>. For some reason, it is pointing the <code>ExceptionInInitializationError</code> at the first enum constant, and the null pointer exception at the enum declaration. I didn't think that an enum declaration could return null.</p>