I am new to stackoverflow which I am finding it very useful, thanks so much for a great community. While I've been understanding about Strings in java, I just wanted to know how are Strings literals source created? I understood most of the concept of Strings in java. It is a special kind of class that is final, I also understood when creating a String literal, an object will be created on the heap and its reference will be in the string constant pool. by using this.
String name = "Manchester";
I also understood that when a string is created using new operator, the reference will have the object on the heap and a reference in the string constant pool. By this way.
String name = new String("United");
As I did understand how the object was created on the heap using the new operator, what I didnt understand is how the object is created on the heap when we use double quotes " ". How is this accomplished? I went thought the source code of String.class too but it wasn't of any help for me.
Can anyone please let me know how this works? Thanks.