raja singh kumar wrote:. . . What if "Raja" is not there in the string pool when that statement is getting executed? . . .
Things like the String pool and the structure of the heap may change from version to version. Escape analysis has already been mentioned; it was introduced in Java6. In Java8 the permanent generation disappeared. How do you know that there will still be a String pool in Java11? Maybe there will be something different.
"Raja" is shown in that code as a String literal. If that code is compiled and executed, the String literal "Raja" will be added to the String pool whenever the class is loaded. How can that String not be in the String pool?