According to Kathy Sierra's book:
String s = "abc"; // creates one String object and one
// reference variable
In this simple case, "abc"
will go in the pool and s
will refer to it.
String s = new String("abc"); // creates two objects,
// and one reference variable
In this case, because we used the new keyword, Java will create a new String object in normal (nonpool) memory, and s
will refer to it. In addition,the literal "abc" will be placed in the pool.
As I know, when we use literals, it stores value in pool but when we use new keyword it creates object in heap. Here I want to know, is the heap object refer pool data (String) or not?