Q:

Why String created using new operator creates string literal in string pool

My Question is what's the use of creating string object in string pool as well as on Heap when we declare String as String a = new String("abc"); What is the advantage ?
And why not we create string in heap when we create string as String a = "abc".

A:

The java language was designed like that. Anything you use between double quotes is a compile time constant and goes into the String pool. So, in your case :
String a = new String("abc");
"abc" will be resolved as a compile time constant and thus will be added to the String constants pool for the current JVM.
Next, the value of a will be resolved at run-time and will be added to the heap during run-time.

A:

First, I recommend that you not use new String("abc") because it behaves as you described. Second, when you use new you should expect a new Object instance will be created and it is.

