Cannot Compare Strings Android Studio after get response from PHP
<p>this is a basic knowledge but I get frustrated after 3 hours of trying.
I am running codes in Android Studio and I just want to compare the result of 2 strings
This is my codes</p>

<pre><code>String result=stringBuilder.toString();
        String wanted="SUCCESS";

        if(result.equalsIgnoreCase("SUCCESS"))
        {
            Log.d("RESULT","FINALLY 1");
        }
        else if(result.equals("SUCCESS")) {
            Log.d("RESULT", "FINALLY 2");
        }
        else if(result=="SUCCESS")
        {
            Log.d("RESULT","FINALLY 3");

        }
        else if("SUCCESS".equals(result))
        {
            Log.d("RESULT","FINALLY 4");
        }
        else if(result.equals(wanted))
        {
            Log.d("RESULT","FINALLY 5");
        }
        else
        {
            Log.d("RESULT",result);
        }
</code></pre>

<p>I have tried every options available on webs but I got the same results and you can see that var "result" is "SUCCESS"</p>

<pre><code>  11-11 23:31:01.477    8116-8152/com.example.asus.ucomm D/RESULT﹕ SUCCESS
</code></pre>

<p>What did I do here that get errors from just comparing strings? Am I too tired until I missed something? Please help.</p>

<p>//EDIT
I get stringBuilder.toString() to get the response from my PHP file. This is the last code that checks the database</p>

<pre><code>if(isset($_GET['user']))
{
    $findFriend=$_GET['user'];
    $sql = "SELECT * FROM username WHERE pin='$findFriend'";
}
$result = $conn-&gt;query($sql);

if ($result-&gt;num_rows &gt; 0) 
{
    echo "SUCCESS";
}
else echo "NOT FOUND";
</code></pre>

<p>//EDIT 2
The result before trim() is</p>

<pre><code> 11-12 00:07:56.057    6000-6036/com.example.asus.ucomm D/RESULT﹕ +SUCCESS
+
</code></pre>

<p>I thought that it ran out of space. But it had /n </p>