 <p>To check if two strings are the same in Java, use <code>.equals()</code>:</p> <pre><code>"1" == new String("1") //returns false "1".equals(new String("1")) //returns true </code></pre> <p>EDIT: Added new String("1") to ensure we are talking a new string.</p>