title: Null Pointer Exception in Java when using String Arrays
body: <p>I have a piece of code where the program compares the value of two arrays of strings. I am getting a <code>java.lang.NullPointerException</code>, even though I initialized both arrays. Here is the relevant code:</p>
  
  <pre><code>String[] functions=new String [inputs+1];
  int funCounter=0;
  for (int a=0;a&lt;2;a++)
  {
      for (int b=0;b&lt;2;b++)
      {
          if (tokenizedString[b].equals(keywords[a])&amp;&amp;keywords[a].equals("add"))
          {
              System.out.println("Yay");
              functions[funCounter]="add";
              funCounter++;
          }
          }
      }
  </code></pre>
  
  <p>This is where I inialize tokenizedString:</p>
  
  <pre><code>String[] tokenizedString;
      tokenizedString=new String[2];
  </code></pre>
  
  <p>tokenizedString is added to a Scanner in stream here:</p>
  
  <pre><code>StringTokenizer st = new StringTokenizer(input," ");
  </code></pre>
  
  <p>And here is where I initialize keywords:</p>
  
  <pre><code>String[] keywords;
      keywords=new String[2];
  </code></pre>
  
  <p>Any ideas? Thanks!</p>