title: Null Pointer Excpetion when trying to test if array is empty java
body: <p>I was tyring to test if my array is empty, but I always get a null pointer exception for some reason. I don't understand since my test actually test if the value is null. Here is the code where it gets stucks. I get the null pointer on the While loop:</p>
  
  <pre><code>private int findIndex(String key) {
          int index = calculateHashCode(key);
          while (table[index] != null &amp;&amp; !table[index].getKey().equals(key)) {
              index = (index + 1) % TABLE_SIZE;
          }
          return index;
      }
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>table is declared like this:</p>
  
  <pre><code>static HashEntry[] table;
  </code></pre>