variable containing a string fails == test with 'the same' string. Why?
<p>I'm an idiot:</p>

<p>My code is the code below. I ran the code, and input 4 as my answer. However, the program still tells me the answer is incorrect. What did I do wrong? Thank you so much for the help.</p>

<pre><code>import java.io.*;

class class1 {

  public static void main (String[] args) throws IOException { 
    BufferedReader input = new BufferedReader (new InputStreamReader(System.in));
    System.out.println("What is the answer to 2 + 2");
    String answer;

    answer = input.readLine();

    if ( answer == "4"){
      System.out.println("Correct");
    } else System.out.println("Incorrect");

    }
  }
}
</code></pre>
