title: Choosing random word from an ArrayList?
body: <p>I currently have a project for my computer science class that requires me to choose a random word from a text file. So far I've gotten the text file into an array and currently can print the entire thing, yet for the life of me I cannot figure out to grab a random word from it..? I know the code is messy and unorganized, sorry. Thanks in advance! &lt;3</p>
  
  <pre><code>package moviemain1;
  
  /**
  *
  * @author rogerseva
   */
  import java.io.*;
  import java.util.*;
  
  public class MovieMain1 {
  
  /**
   * @param args the command line arguments
   * @throws java.io.IOException
   */
  public static void main(String[] args) throws IOException {
      Scanner scan = new Scanner(new File("movies.txt"));
      int numOfMovies = 0;
      int randomMovie = 0;
      String movies = "";
      String s = scan.nextLine();
      args = s.split("");
      ArrayList&lt;String&gt; movieList = new ArrayList&lt;String&gt;();
  
  
  
       while (scan.hasNextLine()) {
       movieList.add(scan.nextLine());
      }
  
      while (scan.hasNextLine()) {
          String line = scan.nextLine();
          movies += (line + "\n");
          numOfMovies++;
          randomMovie = (int) (Math.random() * numOfMovies);
      }
  
  
      System.out.println(movieList);
  
  
  
  
       }
     }
  </code></pre>