title: Trouble with Java Hangman game
body: <p>I made an algorithm for my java hang man game that adds the users guess to an array that matches the guess to a letter in the word. If the answer is correct it adds the letter to arraylist guesses in the same spot as it is in the word. Once the method is done  For some reason the answer always returns incorrect.                         </p>
  
  <pre><code>  public class HangMan
  {
     public final int GAME=9;
  public void Hangman()
  {
  words();
  }
  String nerd="";
  public void words()
  {
  Scanner in = new Scanner(System.in);
  Random randomgenerator =new Random();
  int random = randomgenerator.nextInt(4);
  String myArray[]={"albatross","cat","mitosis","computer","coding"};
  nerd=myArray[random];
  //get length of word
  int length=nerd.length();
  
         //create hangman
         System.out.println(" ------");
         System.out.println(" |");
         System.out.println(" |");
         System.out.println(" |");
         System.out.println(" |");
         System.out.println("____");
         System.out.println("Guess a letter!"); 
  
  
  
         //create dashes
         for(int z=0;z&lt;length;z++)
         {
           System.out.print("_");
         }
      }
  
  
  
  
  public void check()
  {   
  
  ArrayList&lt;String&gt;guesses=new ArrayList&lt;String&gt;();
    //Inputs a scanner
    Scanner in = new Scanner(System.in);
  
          // pre condition:if player guess equals a char in nerd 
  
             String guess1=in.nextLine();
             char guess=guess1.charAt(0);
             for(int i=0;i&lt;nerd.length();i++)
             {
  
             }
                if(guess==nerd.charAt(z))
                {
  
  
                   System.out.println("Correct");
                   System.out.println("Your word so far");
                   System.out.print(guesses);
                    guesses.set(z, guess+"");
                   System.out.println("You have");
                   System.out.print(nerd.length()-z);
                   System.out.print("guesses left");
  
                }
  
  
  
             //pre condition: if the guess is wrong
             else
             { 
             System.out.println("Wrong");
             System.out.println("Your word so far");
             System.out.print(guesses);
             System.out.println("You have");
             System.out.print(nerd.length()-z);
             System.out.print("guesses left");
  
             }
  
          }
  </code></pre>