title: Bible unique word counter bottleneck
body: <p>We are suppose to make a program which counts all of the unique words found in a text file of the King James Bible and prints out the most frequently used words. My function to count the number of unique words is taking way too slow: </p>
  
  <pre><code>public int parseBook(File fileName) throws FileNotFoundException {
  
      scan = new Scanner(fileName);
      String currentWord = scan.next();
      Word firstWord = new Word(currentWord);
      allWords.add(firstWord);
      wordCount++;
      while(scan.hasNext()) {
          currentWord = scan.next();
              Word newWord = new Word(currentWord);
              if(!allWords.contains(newWord)) {
                  uniquewordList.add(newWord);
  
  
              }
  
              else {
                  newWord.incrementFrequency();
              }
              allWords.add(newWord);
  
      }
      return uniquewordList.size();
  }
  </code></pre>