title: java newbie: reading in a file for word search code. .add() and .toArray() is giving me errors
body: <p>I'm really trying to figure out what's wrong with this code. The .add() and .toArray() have red lines underneath them. Is there some kind of alternative to writing those two lines? What am I doing wrong?</p>
  
  <pre><code>package prog3;
  
  import java.io.BufferedReader;
  import java.io.FileReader;
  import java.io.IOException;
  import java.util.*;
  
  public class WordList {
  
      private String filename;
      private Word[] words;
  
      public WordList(String fileName) {
          this.filename = fileName;
      }
  
      //reads in list of words and stores them internally. line by line 
      //if method reas list of words successfully, then it returns as true, otherwise false
  
      public boolean readFile() {
  
          try{
              BufferedReader read;
              read = new BufferedReader(new FileReader(filename));
              String nextLine;
              while ((nextLine = read.readLine())!= null) {
                  nextLine = nextLine.trim();
                  read.add(new Word(nextLine));
              }
  
              words = read.toArray(new Word[0]);
          }catch(IOException ex){
              System.out.println("Caught exception: " +ex.getMessage());
              return false;
          }
          return true;
      }
  
  //getList is supposed to return the list of words as an array of class Word. How do I do this???
  
  public Word[] getList() {
  
      }
  } 
  </code></pre>