title: null pointer exception on adding string object to arraylist
body: <p>Cant get around this. Null Pointer exception occurs when trying to add a String object to an ArrayList. Trouble is, I believe I have already initialized the 'temp' ArrayList properly. Please help.        </p>
  
  <pre><code>void initialConbinations(String[] headers) {
      //Dataset is SN,FN,RN,PN
      //Map the headers to the appropriate portions
      String[] newHeaders = {"SN,high", "SN,medium", "SN,low", "FN,high", "FN,medium", "FN,low", "RN,high", "RN,medium", "RN,low"};
      List&lt;List&gt; assRuleHeaders = new ArrayList&lt;List&gt;();
      ArrayList&lt;String&gt; temp = new ArrayList&lt;String&gt;();
  
      //Use bitwise shifting to do the rest
      int k = 0, l = 0;
      for (int i = 1; i &lt; 511; i++) {
          for (int j = 0; j &lt; 9; j++) {
              l = i;
              k = (l &gt;&gt; j) &amp; 0x00000001;
              if (k == 1) {
                  System.out.println(k + " , " + i + " , " + j);
                  System.out.println(newHeaders[j]);
                  temp.add(newHeaders[j]);    //Getting a Null Pointer Exception here
              }
          }
          assRuleHeaders.add(temp);
          temp = null;
      }
  
      for (int i = 0; i &lt; assRuleHeaders.size(); i++) {
          this.printArray(assRuleHeaders.get(i));
      }
  }
  </code></pre>