Originally posted by chintan ramavat:
want to know bit about Strings
String s1 = new ("Java");
String s2 = "abc";
I think here total 4 objects will be created technically
2 of them for non-pool memory i.e. s1 and s2
2 of String pool i.e. java, abc ; which are the new values in pool ;
I am confused about it, would you help me out ?
Thanks in advance
I would say there are 3 objects. s1 and s2 are references to Strings. But there is one object created by new if you include the word
String, and then two String literals.
[ March 01, 2007: Message edited by: Keith Lynn ]