Cannot create test condition after using nextLine()
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/767372/java-string-equals-versus">Java String.equals versus ==</a>  </p>
</blockquote>



<p>I have been having difficulties using nextLine() to get a string, and then use it as a test condition (either in an if statement or a while loop).  Looking at the println(), it seems as if the String is correctly assigned to the variable 'repeat' but then the test condition fails for some reason.  Banging my head on the wall, bleeding from my forehead. Please help.</p>

<pre><code>import java.util.Scanner;

public class potpie {

    public static void main(String args[]){

        Scanner input = new Scanner(System.in);
        String repeat = "yes";


        System.out.println("Type in yes");
        repeat = input.nextLine();
        System.out.println("If repeat is now yes, print yes:  " +repeat);

        if(repeat == "yes"){
            System.out.println("It worked");
        } else
            System.out.println("it failed");
    }
}
</code></pre>
