Subhadeep biswas wrote:"i am","i am string"
These two definitely won't exist. There are no spaces in your strings and concatenation doesn't automatically add them.
Subhadeep biswas wrote:acc to me in the string pool strings would be "i","am","string","i am","i am string"..i don have idea on heaps existence...please help me in
The compiler will optimise your code to
so the Strings in the pool will be
i,
iam,
string and
iamstring (due to the String literals)
There will also be a second String with the value
string created by the
new String call
All these Strings will be on the heap, although possibly in different parts of the heap.