The differnce in term of memory is that the expressions of the form :
String s = "test" uses the "interned" string so as to share unique instances.
The invocation of form: String s = "test"
is efficient compared to String s = new String("test")
The first call makes use of the existing constant expression (if there is one),
the second call creates a new instance without making use of any existing instance.
Below code chunk demonstrates this:
String test = new String("test");
String internTest = "test";
String nonInternTest = new String("test");
System.out.println(test == internTest); // prints false
System.out.println(test != nonInternTest); // prints true
System.out.println(test.equals(nonInternTest)); // prints true
Also note that the JLS specifies the behavior to be thus:
Each string literal is a reference to an instance of class String (§4.3.3). String objects have a constant value. String literals-or, more generally, strings that are the values of constant expressions are "interned" so as to share unique instances, using the method String.intern.