Compile-time string expressions are put into the String pool. s=s+"JVM" is not a compile-time constant expression. so everytime it creates a new string object in heap.
for more details see this Behavior of String literals is confusingBehavior of String literals is confusing