Lokesh ,
When you say
String a = new String("a") ;
you are always creating a new String object.
But when you say String a = "a"
you will not always create a object .
Because , JVM internally maintains a pool of strings.
so if there is already a string object with content "a" then
instead of creating a new string object , your exisiting object in a pool will be used.
(a == b) operator is used to
test whether two refrences are pointing to same object or not.
so when you create a string using a second method , it wil return a true as both refresnces will point two same string object.
But when you create a string using "new" operator , JVM will neccessarily create a new string object and so there refrences will point to two different objects and == will return false .