Initially only the array itself will be created with null references. The actual number of objects created by the JVM will always depend on the actual content of the arry when creating arrays of object references.
Originally posted by Anil Kumar Saha: for the second expression, it will be 22. inside heap--> 1 String Array object,10 String Objects inside String Literal pool--> 1 String Array object,10 String Objects.
Correct me if I'm wrong.
You're wrong. The answer is 2.
This thread appears to have become more complex than is necessary to answer the original question - which has nothing to do with "the pool" (the apparently abstract concept that few understand but many like to talk about).
Tony Morris Java Q&A (FAQ, Trivia)
Won't you please? Please won't you be my neighbor? - Fred Rogers. Tiny ad: