string pool in java
Or is it the case that in first case we have a string pool wherein we have a string literal whose value is "java" and the reference of that string literal in the string pool is returned to the object in the heap created by the expression new String("java") ,and now the reference of this object is actually returned to the reference variable a.
And in the second case we have the reference variable a directly pointing directly to the string literal "java" which is present in string pool.