There are 2 ways to create String Objects in
Java
(1) Using the new operator i.e.
(2) Using the String Literal i.e.
.
.
Now String allocation is costly in both time and memory so the JVM(Java Virtual Machine) performs some tasks? WHAT TASKS?
See whenever you are using the "new" operator the object is created, JVM will not look in string pool it is just going to create the Object, but when you are
using the string literals for creating String objects then JVM will perform the task of looking in the string pool i.e.
When you will write
the JVM will look in string pool and check if "abc"already exists or not. If it exists then then a reference is returned
to the already existed string "abc" and new object is not created and if it doesn't exists then a object is created.
So in your case
(a)
--------Since "new" is used to therefore Object is created
(b)
----using String literal a object is created and "abc" is not in string pool therefore Object is created
(c)
----Again using String literal and "abc" is in string pool therefore Object is not created.
.
.
You can also check it out by using the following the code
Hope this helps...Note == is used to see if Object are equal and equals(Object) method is used to see if content are equal.