title: fill arrayList with dat file
body: <p>Here's the code:</p>
  
  <pre><code>import java.io.File;
  import java.io.IOException;
  import java.util.Scanner;
  import java.util.ArrayList;
  import java.util.Collections;
  import static java.lang.System.*;
  
  public class MadLib
  {
  private ArrayList&lt;String&gt; verbs = new ArrayList&lt;String&gt;();
  private ArrayList&lt;String&gt; nouns = new ArrayList&lt;String&gt;();
  private ArrayList&lt;String&gt; adjectives = new ArrayList&lt;String&gt;();
  
  public MadLib()
  {
      loadNouns();
      loadVerbs();
      loadAdjectives();
      out.println(nouns);
  }
  
  public MadLib(String fileName)
  {
      //load stuff
      loadNouns();
      loadVerbs();
      loadAdjectives();
  
  
      try{
          Scanner file = new Scanner(new File(fileName));
      }
      catch(Exception e)
      {
          out.println("Houston we have a problem!");
      }
  }
  
  public void loadNouns()
  {
      nouns = new ArrayList&lt;String&gt;();
      try{
          //nouns = new ArrayList&lt;String&gt;();
          String nou = "";
          Scanner chopper = new Scanner(new File ("nouns.dat"));
  
          //chopper.nextLine();
          while(chopper.hasNext()){
              nou = chopper.next();
              out.println(nou);
              nouns.add(nou);
              //chopper.nextLine();
          }
          //chopper.close();
          out.println(nouns.size());
      }
      catch(Exception e)
      {
          out.println("Will");
      }       
  }
  
  public void loadVerbs()
  {
      verbs = new ArrayList&lt;String&gt;();
      try{
          Scanner chopper = new Scanner(new File("verbs.dat"));
          while(chopper.hasNext()){
              verbs.add(chopper.next());
              chopper.nextLine();
          }
          chopper.close();
      }
      catch(Exception e)
      {
          out.println("run");
      }
  }
  
  public void loadAdjectives()
  {
      adjectives = new ArrayList&lt;String&gt;();
      try{
          Scanner chopper = new Scanner(new File("adjectives.dat"));
          while(chopper.hasNext()){
              adjectives.add(chopper.next());
              chopper.nextLine();
          }
          chopper.close();
      }
      catch(Exception e)
      {
      }
  }
  
  public String getRandomVerb()
  {
  
      String verb = "";
      int num = 0;
      num = (int)(Math.random()*(verbs.size()-1));
      verb = verbs.get(num);
      return verb;
  }
  
  public String getRandomNoun()
  {
  
      String noun = "";
      int num = 0;
      if(nouns == null){
          loadNouns();
      }
      double rand = (Math.random());
      num = (int)(rand * (nouns.size()-1));
      out.println(num);
      noun = nouns.get((int) num);
      out.print(noun);
      return noun;
  }
  
  public String getRandomAdjective()
  {
  
      String adj = "";
      int num = 0;
      num = (int)(Math.random()*(adjectives.size()-1));
      adj = adjectives.get(num);
      return adj;
  }       
  
  public String toString()
  {
      String output = "The " + getRandomNoun() + getRandomVerb() + " after the " + getRandomAdjective() + getRandomAdjective() + getRandomNoun() + " while the " + getRandomNoun() + getRandomVerb() + " the " + getRandomNoun();
     return output;
  }
  }
  </code></pre>
  
  <p>and here's one of the .dat files (the other 2 are the exact same aside from the specific words they contain):</p>
  
  <pre><code>dog
  pig
  chicken
  building
  car
  person
  place
  thing
  truck
  city
  state
  school
  student
  bird
  turkey
  lion
  tiger
  alligator
  elephant
  </code></pre>
  
  <p>My issue is that I can't get any of my <code>arrayLists</code> to read in their appropriate .dat files and from my POV, my code seems like it should do that</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>current output aside from the absence of "Will" (I removed that line): </p>
  
  <pre><code>run
  [ ] 
  Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 
  at java.util.ArrayList.rangeCheck(Unknown Source) 
  at java.util.ArrayList.get(Unknown Source)
  at MadLib.getRandomNoun(MadLib.java:130)
  at MadLib.toString(MadLib.java:147) 
  at java.lang.String.valueOf(Unknown Source) 
  at java.io.PrintStream.println(Unknown Source)
  at Lab16d.main(Lab16d.java:18) 
  </code></pre>