title: How can I pick a random word then replace it to a new word?
body: <p>I need to replace a random word that I pick in the MovieList into underscore "___", I think about create a new method to handle it, the new method should be under the class guessMovies, and then I will call method under "object r" to replace every single word into underscore, but Java said it cannot find symbol ( it doesn't know what "r" is ). Please help. </p>
  
  <p>Thank you</p>
  
  <hr>
  
  <p>I put object r out of try/catch scope, and use this code</p>
  
  <pre><code>            String movieToReplace = MovieNames.get(r.nextInt(MovieNames.size()));
          System.out.println(movieToReplace);
          MovieList.replaceAll(movieToReplace, "_");
  </code></pre>
  
  <p>but seem like it still gives me the random movie name, not a underscore "_"</p>
  
  <pre><code>public class guessMovies {
  
  private static Random randomGenerator;
  
  
  
  public static void main(String[] args) throws IOException {
  
      String MovieList;
      ArrayList&lt;String&gt; MovieNames = new ArrayList&lt;&gt;();
      Random r = new Random();
  
  
  
      try (BufferedReader br = new BufferedReader(new FileReader("MovieList.txt"))) {
  
          while ((MovieList = br.readLine()) != null) {
              MovieNames.add(MovieList);
          }
  
          for(String movieName: MovieNames){
              System.out.println(movieName);
          }
  
  
          String movieToReplace = MovieNames.get(r.nextInt(MovieNames.size()));
          System.out.println(movieToReplace);
          MovieList.replaceAll(movieToReplace, "____");
  
      }
  
      catch(FileNotFoundException exception) {
          System.out.println("I cannot find your file");
  
      }
      //pick random movie
  }
  </code></pre>
  
  <p>}</p>
  
  <p>ERROR:</p>
  
  <pre><code>Error:(38, 14) java: cannot find symbol
  </code></pre>
  
  <p>symbol:   method replaceAll(java.lang.String,java.lang.String)
    location: variable r of type java.util.Random</p>