title: Using String Array in HashMap, Java
body: <p>I have a hashmap that contains multiple string arrays. I am trying to output each element in one of the arrays  of the hashmap however I seem to always get</p>
  
  <pre><code>java.lang.NullPointerException
  </code></pre>
  
  <p>Here is my code,</p>
  
  <pre><code>import java.util.HashMap;
  public class TestApp {
      private static HashMap&lt;String, String[]&gt; subjects;
      public TestApp() {
          HashMap&lt;String, String[]&gt; subjects = new HashMap&lt;String, String[]&gt;();
          subjects.put("calculus",new String[] {"math","logic"});
          subjects.put("chemisty",new String[] {"ions","electrons"});
          subjects.put("biology",new String[] {"life","bacteria"});
      }
      public static void main(String[] args){
          for(String s:subjects.get("biology")){
              System.out.println(s);
          }
      }
  
  
  }
  </code></pre>
  
  <p>How can i stop this issue?</p>