if(...) - two equal sides are considered as not equal
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java">How do I compare strings in Java?</a>  </p>
</blockquote>



<p>im new to android and this is my first post in StackOverflow.In short I face a very strange problem :
    in some methods I used if(...) ,and both of the values were equal ,yet it doesn't go through the if .
    Here is an example :</p>

<pre><code>String []s=db.getStudentsNames();
        String []t=CopyNames(s);
        String t1,t2;

        t2=Id.getText().toString();
        for(int i=0;i&lt;s.length;i++)
        {
            t1=t[i].substring(t[i].indexOf("-")+1).toString();
            Notifications(t[i].substring(t[i].indexOf("-")+1).toString());
            if(t1.toString()==t2.toString())//Problem!
            {
                Notifications("Id already exists for "+t[i].substring(0,t[i].indexOf("-")).toString());
                return false;
            }
        } 
</code></pre>

<p>The variables t1 &amp; t2 are : <code>t1="123456789"</code> &amp; <code>t2="123456789"</code> , yet it doesn't enter the if like they are not equal.
And there are other places were two equal sides are considered as not equal - in the same java page (activity) like:
<code>if(add.getText().toString()=="Add Student")</code> : add refers to a button which has ,by default , a text :"Add Student" 
so how can I solve this problem ?</p>

<p>**when this problem started , I started to see in LogCat:</p>

<pre><code> W/KeyCharacterMap(282): No keyboard for id 0

 W/KeyCharacterMap(282): Using default keymap: /system/usr/keychars/qwerty.kcm.bin

 D/dalvikvm(282): GC_FOR_MALLOC freed 5438 objects / 256800 bytes in 73ms
</code></pre>
