("kg"=="kg") returns false. How Do I tell java, that this comparison returns true?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/995918/java-string-comparison">Java string comparison?</a>  </p>
</blockquote>



<p>I was trying to do this:</p>

<pre><code>boolean exit = false;
while(exit==false &amp;&amp; convStoreIndex&lt;convStoreLength) {
  if(conversionStore[convStoreIndex].getInUnit()==inUnit) {
    indexCount++;
    exit=true;
  }
  convStoreIndex++;
}
</code></pre>

<p>but the if-condition never went true, even if the two Strings were the same(checked this in the debugger).
so I added some lines:</p>

<pre><code>boolean exit = false;
while(exit==false &amp;&amp; convStoreIndex&lt;convStoreLength) {
  Log.v("conversionStore["+String.valueOf(convStoreIndex)+"]", conversionStore[convStoreIndex].getInUnit()+"|"+inUnit);
  String cs = conversionStore[convStoreIndex].getInUnit();
  String iu = inUnit;
  Log.v("cs", cs);
  Log.v("iu", iu);
  Log.v("Ergebnis(cs==iu)", String.valueOf(cs==iu));
  if(conversionStore[convStoreIndex].getInUnit()==inUnit) {
    indexCount++;
    exit=true;
  }
  convStoreIndex++;
}
</code></pre>

<p>and here is the extract from LogCat:</p>

<pre><code>09-15 11:07:14.525: VERBOSE/cs(585): kg
09-15 11:07:16.148: VERBOSE/iu(585): kg
09-15 11:07:17.687: VERBOSE/Ergebnis(cs==iu)(585): false
</code></pre>

<p>the class of conversionStore:</p>

<pre><code>class ConversionStore {
  private String inUnit;
  [...]
  public String getInUnit() {
    return inUnit;
  }
}
</code></pre>

<p>Who is going crazy, java or me?</p>
