title: Maximum search factor and average search factor java
body: <p>I need to find the max search factor and average search factor in a table. </p>
  
  <p>I have statistics of what it is supposed to be and my statistics keeps coming out to be greater than that given.</p>
  
  <pre><code>public void printStatistics() {
      int numFilledLocations = 0;
      for (Hash hash: hashTable) {
          if (!hash.val.isEmpty()) {
              numFilledLocations++;
          }
      }
      System.out.println("Load Factor: " + ((float) numFilledLocations) / (float) tableSize);
      int maxLength = 0;
      int totalLengths = 0;
      for (Hash hash: hashTable) {
          int length = 1;
          Hash nextHash = hash;
          while (nextHash.next != -1) {
              length++;
              nextHash = hashTable[nextHash.next];
          }
          if (length &gt; maxLength) {
              maxLength = length;
          }
          totalLengths += length;
      }
      System.out.println("Sum of length linked list: " + totalLengths);
      System.out.println("Maximum Search Factor: " + maxLength);
      System.out.println("Average Search Factor: " + ((float) totalLengths / (float) tableSize));
  }
  </code></pre>