how many Strig objects get created from following code: String s1= new String("hi"); String s2="hi"; i thik two.for String s1 two objects,one get lost in Strig pool & another is referred by s1.then s2 refers to the same string which get lost in string pool. is it correct? thanks in advance..
Hi Prajkta, Yes there will be 2 objects created as you mentioned. FYI, this topic has been discussed very frequently here. This link will take you to one of those threads.