title: Trying to use hashmap to count frequency of words in array
body: <p>This is my code:</p>
  
  <pre><code>public static void main(String args[]) throws Exception
  {
      BufferedReader infile = new BufferedReader(new FileReader(args[0]));
      HashMap&lt;String,Integer&gt; histogram = new HashMap&lt;String,Integer&gt;();
      while ( infile.ready() )
      {   
          String SPACE = " ";
          String [] words = infile.readLine().split(SPACE);
  
          for (String word : words)
          {
              Integer f = histogram.get(word);
              histogram.put(word,f+1);
          }   
      }
      infile.close();
      printHistogram( histogram );
  }
  private static void printHistogram( HashMap&lt;String,Integer&gt; hm )
  {
      System.out.println(hm);
  }
  </code></pre>
  
  <p>I keep getting a NullPointerException for the " histogram.put(word,f+1);" part. why is this?</p>