title: Adding all the words from a .txt file to an ArrayList of Custom objects
body: <p>I have a .txt file in which every line has a single word.  I've created a class called <code>Word</code> with a string variable and ArrayList variable.  My objective is to loop through the entire .txt file and store every word in there as an <code>Word</code> object.  For example, if the word is "philly", then an object of the class Word would be created with the String <code>philly</code> and a Character ArrayList would be created as <code>[p,h,i,l,l,y]</code></p>
  
  <p>The code below will work to store every word in the .txt file in a String ArrayList but my objective with this project has since changed and I now need a way to store it as objects with both variables, not just the string.  The line that I specifically need to replace is <code>objectArray.fillWord(strLine);</code>.  It is currently giving me the error message <code>The method fillWord (String) is undefined for the type ArrayList &lt;Word&gt;</code>.  How do I alter this to add a specific Word object to the objectArray of Word objects? How can I create an instance for every single word in the txt file within this loop that gives each Word the same name as it has in the txt file? Any help is truly appreciated!</p>
  
  <pre><code>import java.awt.List;
  import java.io.BufferedReader;
  import java.io.File;
  import java.io.FileNotFoundException;
  import java.io.FileReader;
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.Scanner;
  import java.util.Set;
  
  public class WordRecommender {
  
  public static void main(String[] args) {
  
     StringBuilder sb = new StringBuilder();
     String strLine = "";
     ArrayList&lt;Word&gt; objectArray = new ArrayList&lt;Word&gt;();
     try {
          BufferedReader br = new BufferedReader(new FileReader("engDictionary.txt"));
           while (strLine != null)
            {
             strLine = br.readLine();
             sb.append(strLine);
             sb.append(System.lineSeparator());
             strLine = br.readLine();
             if (strLine==null)
                break;
             objectArray.fillWord(strLine);
         }
          br.close();
     } catch (FileNotFoundException e) {
         System.err.println("File not found");
     } catch (IOException e) {
         System.err.println("Unable to read the file.");
     }
  }
  </code></pre>
  
  <pre><code>import java.util.ArrayList;
  
  public class Word {
  
      String wordName;
      ArrayList&lt;Character&gt; uniqueLetters;
  
      public Word(String wordName, ArrayList&lt;Character&gt; uniqueLetters) {
          this.wordName = wordName;
          this.uniqueLetters = uniqueLetters;
      }
  
      public Word fillWord(String string) {
  
          ArrayList&lt;Character&gt; tempArray = new ArrayList&lt;Character&gt;();
  
          for (int i = 0; i &lt; string.length(); i++) { 
                          tempArray.add(string.charAt(i));
                      }
  
          Word w = new Word(string, tempArray);
  
          return w;
      }
  
  }
  </code></pre>