hi mansoor
this is what i think:
1.
String str="String"; //gets put into a string pool
str.toString() //returns 'String', but 'String' is already in string pool
"String".toString() // returns 'String', but 'String' is already in string pool
so they both have reference to the same string, so '==' returns true.
2.it seems that with this, both statements
"String".replace('g','G') check the string pool and find that there is no matching string, so they both return different references. so unequal.
if u said ("String".replace('g','G')).intern() to both it would return equal as they would both be put in the string pool but the strings are the same so they would both refer to onw string so same reference.
3.with this, both statements
("String".replace('t','t') check the string pool and find a matching string so they both return the same reference, so equal
[This message has been edited by lee dalais (edited March 30, 2001).]