Possible Duplicate:
How do I compare strings in Java?
i have written some code which compares two strings "abc" and "de". The string abc is parsed and returned to "doc" to ext and then it is compared. Although it seems that if condition is true but still the else part is executing. where i am not getting plz help me ....thanks a lot.
public class xyz{
String abc="doc2.doc";
String de="doc";
public static void main(String arg[]){
xyz c=new xyz();
String ext = null;
String s =c.abc;
String d =c.de;
int i = s.lastIndexOf('.');
if (i > 0 && i < s.length() - 1){
ext = s.substring(i+1).toLowerCase();
}
System.out.println(ext);
if(ext==d){
System.out.println("true");
}
else{
System.out.println("false");
}
}
}