Equal substring value does not return expected result
<p>Hi I have a problem with this substring where I expected it to be equal. Well I made a function where you will compare two names then whenever those names share a same character it will change all that characters into spaces. Can you check where is my mistake in this one? I'm having a hardtime to figure it out. Here's my code:</p>

<pre><code>name1 = name1.replace(" ","");
    name2 = name2.replace(" ","");

    Log.v(TAG, name1);
    Log.v(TAG, name2);

    Log.v(TAG, String.valueOf(name1.length()));
    Log.v(TAG, String.valueOf(name2.length()));

    for (int x=0; x &lt; name1.length(); x++){
        for (int y=0; y &lt; name2.length(); y++){

            Log.v(TAG, "Value of LOOP : "+"-"+String.valueOf(y) +"-"+String.valueOf(x)+"-");
            Log.v(TAG,"-"+name1.substring(x)+"-"+name2.substring(y)+"-");

            if (name1.substring(x) == name2.substring(y)){
                Log.v(TAG, "Value of XY : "+String.valueOf(y)+","+String.valueOf(y));

                name1 = name1.replace(name1.substring(x)," ");
                name2 = name2.replace(name2.substring(y)," ");
            }
        }
     }
    Log.v(TAG,"LOOP SUCCESS");

    String name3 = name1 + name2;
    Log.v(TAG,"Name 3 Value: "+name3);
</code></pre>
