Read this piece of code carefully
if("String".replace('g','G') == "String".replace('g','G'))
System.out.println("Equal");
else
System.out.println("Not Equal");
Answers
1.the code will compile an print "Equal".
2.the code will compile an print "Not Equal".
3.the code will cause a compiler error
Answer is 2.
I thought answer would be 1 because "StrinG" will exist in the
String constant pool.
can anybody tell me whether "StrinG" will be placed on heap or in String constant pool?