Originally posted by Karthik Rajashekaran: String s1 = new String("amit"); System.out.println(s1.replace('m','r')); System.out.println(s1); String s3="arit"; String s4="arit"; String s2 = s1.replace('m','r'); System.out.println(s2==s3); //XYZ System.out.println(s3==s4);
Why is the out put at XYZ is false ?though both reference to same "arit"
I think both s2 and s3 do not refer to same object. s2 refers to a String Object in pool, whereas s3 refers to a new object created by the statement earlier: String s2 = s1.replace('m','r'); replace method always returns a new String Object even if that string is already present in the pool.
Correct me if I am wrong.
Regards<br />Sandy<br />[SCJP 5.0 - 75%]<br />[SCWCD 1.4 - 85%]<br />------------------<br />Tiger, Tiger burning bright,<br />Like a geek who works all night,<br />What new-fangled bit or byte,<br />Could ease the hacker's weary plight?
Joined: Aug 31, 2005
yes you are right
again i made silly mistake
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com