title: Resetting a variable to new value in loop
body: <p>I have a small hang man type game in which the user guesses a letter and tries to determine one of the random words from a string array. The issue is that once the user wants to play again with a new random word, the old word still shows up along side with it ?</p>
  
  <pre><code>import java.util.Random;
  import java.util.Scanner;
  import java.lang.Character;
  
  public class Game
  {
      public static void main(String[] args)
      {
          String[] words = {"Computer", "Software" , "Program" ,
                            "Algorithms", "Unix" , "Mathematics" ,
                            "Quick" , "Bubble" , "Graph" };
  
          Random rnd = new Random();
          Scanner sc = new Scanner(System.in);
  
          int index;
          String word = "", 
          invisibleWord = "", 
          newString = "", 
          guess,
          status;
  
          while(true)
          {
              index = rnd.nextInt(words.length);
              word = words[index];
  
              for(int i = 0; i &lt; word.length(); ++i)
                  invisibleWord += "*";
  
              while(true){
                  System.out.print("(Guess) Enter a letter in word "
                                     + invisibleWord + " &gt; ");
  
                  guess = sc.nextLine();
  
                  for(int j = 0; j &lt; word.length(); ++j)
                      if(guess.toUpperCase().equals(Character.toString(word.charAt(j)).toUpperCase())){
                          if(j == 0){
                          newString = invisibleWord.substring(0,j) + guess.toUpperCase() + invisibleWord.substring(j + 1);
                          invisibleWord = newString;
                          } else {
                          newString = invisibleWord.substring(0,j) + guess + invisibleWord.substring(j   + 1);
                          invisibleWord = newString;
                          }
                  }
  
                  if(invisibleWord.contains("*")) continue;
                  else break;
  
          }
                      System.out.println("The word is " + word);
                      System.out.print("Do you want to guess another word ? " +
                                         "Enter y or n &gt; ");
                      status = sc.nextLine();
                      if(status.toUpperCase().equals("Y")) continue;
                      else if(status.toUpperCase().equals("N")) break;
  
      }
  
  
  }
  }
  </code></pre>
  
  <p>SAMPLE RUN:</p>
  
  <pre><code>(Guess) Enter a letter in word ****** &gt; a
  (Guess) Enter a letter in word ****** &gt; e
  (Guess) Enter a letter in word *****e &gt; i
  (Guess) Enter a letter in word *****e &gt; o
  (Guess) Enter a letter in word *****e &gt; u
  (Guess) Enter a letter in word *u***e &gt; b
  (Guess) Enter a letter in word Bubb*e &gt; l
  The word is Bubble
  Do you want to guess another word ? Enter y or n &gt; y
  (Guess) Enter a letter in word Bubble******** &gt; 
  </code></pre>
  
  <p>The problem occurs in the last line, why is Bubble still showing up as a word when it is supposed to be reset to a new random word ?</p>