Originally posted by Rahul Pawar:
[Output will be not equal
bcoz when u use any method of string class , it's creates new string object and hence trim()will creat new string and hence results false condition
rahul
Hi
But if you do
if("String".replace('t','t') == "String")
System.out.println("Equal");
else
System.out.println("Not Equal");
it returns Equal. I am a bit confused: if you use a String method and a new string is created, why does it sometimes return true and sometimes false, in the case of trim();
Or am I missing something really basic. Help!!
Regards,
Sabrina